Announcement

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

    Missing API: Serverside DSResponse constructor / setter with DataSource as String

    Hi Isomorphic,

    I'm transitioning existing 5.1p server code that was used from the client to work from server/servlet use as well, making it not depend on a RPCManager-instance presence.

    This works well so far, but now I'm at a position where I need to fake a DSResponse in order not execute an expansive statement.
    Before I used this in a method returning a DSResponse:
    Code:
    fetchResponse = new DSResponse(rpcManager.getDataSource(dataSource.getValue()), BaseResponse.STATUS_SUCCESS);
    ...
    ...
    return fetchResponse;
    But now I don't have rpcManager.

    Can I do this?
    Code:
    DataSource tempDS = DataSourceManager.get(dataSource.getValue());
    fetchResponse = new DSResponse(tempDS, BaseResponse.STATUS_SUCCESS);
    DataSourceManager.free(tempDS);
    ...
    ...
    return fetchResponse;
    Even if this is valid usage, a String-constructor for DSResponse (like for DSRequest) would be the cleaner solution IMHO.
    What is your suggestion here?

    Thank you & Best regards
    Blama


    #2
    Because you don't have an RPCManager, we can't offer a String-based constructor since there is no way for the DSRequest to know when to free the DataSource - you need to do so.

    Comment


      #3
      Hi Isomorphic,

      are you also talking about DSResponse (and not DSRequest)?
      I want to fake a response, no DataSource/DB action involved. The object should just be used to be returned to the client. Perhaps I'm not getting the bigger picture here, but I think that this does not involve getting and freeing a DataSource-instance, does it?

      Best regards
      Blama

      Comment


        #4
        It does. DSResponse uses DataSources for multiple different reasons, including figuring out how data is to be serialized.

        Comment


          #5
          OK, that's the bigger picture then. Thanks for explaining.

          Is the code I showed in #1 OK? Get a DataSource, fake my DSResponse, return the DataSource and then continue working with the DSResponse object?

          Comment


            #6
            You can't free it that soon, you need to free it once you've completed working with the DSResponse.

            Comment

            Working...
            X