Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Question regarding server method parameters

    Hi,
    most of my datasources are invoked on-server using Spring services. You have parameter matching for some things, like DSRequest, request Maps etc. which is great.

    However, if I would like to have some custom parameter-matching, for example matching a parameter in the http request to a method parameter if it exists and has a certain name, is this possible in some convenient way. Running 6.0 I can see that you have the Reflection class that seems to handle this?

    #2
    Sorry this sat for a while..

    We don’t have a feature that would map from HTTP parameters to method parameters.

    Whatever declaration would be required doesn’t seem like it would be shorter than the code to retrieve the parameter value. But if it somehow would make a big difference in your code, there’s always Feature Sponsorship.

    Remember that you shouldn’t pass things as HTTP params if they would affect how a DSRequest is executed. For example, putting criteria into HTTP parameters would interfere with automatic cache synchronization.

    Comment


      #3
      Here's an example of something i would love to be able to extend:

      In later versions of Spring, you have the @AuthenticationPrincipal parameter. This allows you to specify a custom spring security class, and if it matches the object in the Authentication Principal, Spring will automagically retrieve it and insert it as a parameter:

      Code:
      public LocationTO add(@AuthenticationPrincipal CustomUserDetails details, @RequestBody LocationTO to) {
      So, when i use this as part of a Spring MVC request, it works, but it is called by IdaCall, it won't. Therefor, i would have loved if i could somehow extend IDACall so that it can understand how to extract and insert that parameter too.

      Comment


        #4
        We keep recommending two approaches to you:

        1. Server Scripting to grab the necessary param

        OR

        2. centrally put anything you want as httpRequest attributes

        This seems like rather little code to achieve what you want. You seem to want to be able to declare this somehow - can you suggest a way that you might declare this that would be shorter or simpler than the approach we've already suggested?

        Comment


          #5
          This specific example wasn't related to http, it was a pretty neat way to look up the security principal without having to have the same lines of code in every method. It's not a big deal, just makes the code cleaner and more testable.

          Comment


            #6
            Here's one way we could support this: you would be able to register additional, standard DMI parameters. The registration would provide the parameter className, and a ServerObject definition which tells the framework how to find an instance of the parameter. The ServerObject would receive all the usual context (HttpRequest, DSRequest, etc) and perhaps some additional context (target method name, parameter name, etc).

            This could be done in Java with a new method like DMI.registerCustomParameter(className, serverObject), although it could also be imagined as an XML declaration, perhaps allowed system-wide and also per-DataSource.

            This could be done as a relatively small Feature Sponsorship, if you're interested, or perhaps can find other forum users who are also interested.

            As we've covered, we feel like we have features that are actually a better approach, more dynamic (no Java compilation required), and more transparent (we've seen a number of projects where DI created spaghetti code even worse than the usual spaghetti, because of all the layers of Java Reflection involved). But, this feature could be useful to people who are very Spring-oriented, or have large existing Spring codebases.

            Comment


              #7
              Haha i love the saying "worse than spaghetti" - gotta start using that! :)

              This sounds like a great feature for your product and something i could use. I'd be happy to beta test and give feedback on and I'm sure others would find it great too.

              Regarding your features that would be a "better approach", if you're curious i could give you some feedback offline as to why i'm not so inclined to go that route.

              Thanks again for your great feedback.

              Comment

              Working...
              X