Announcement

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

    Enhancement / convenience API: new constructor for serverside DSRequest

    Hi Isomorphic,

    I'm currently making some of my existing 5.1p server code, that was used in a RPCManager-only setting before to work in a non-RPCManager setting (servlet) as well. In normal DMI, I always create DSRequests like this:
    Code:
    DSRequest childRequest = new DSRequest("dsName", DataSource.OP_XXX, parentRequest.getRPCManager();
    This "just works" and one has not to care about stuff like userId, transaction handling and RequestContext.


    Could you create a constructor
    Code:
    DSRequest(String dsName, String operationType, DSRequest parentRequest)
    Behavior would be to copy settings from the parentRequest as needed. This is the RPCManager, or if not present DSTransaction. If DSTransaction also not present userId. RequestContext as needed.

    Would this make sense?

    Best regards
    Blama

    #2
    We'd prefer not to add such an API since it's not obvious what exactly will be used from the passed DSRequest. Different developers might want or assume different sets of properties. We'd suggest just making yourself a utility method that copies whatever properties make sense in your application.

    Comment


      #3
      Hi Isomorphic,

      I already made such a method. I will keep using it then.

      In case anyone is interested in it:
      Code:
          public static void prepareRequest(DSRequest dsRequest, RPCManager rpcManager, DSTransaction dsTransaction, Long userID,
                  RequestContext requestContext) throws Exception {
              if (rpcManager != null) {
                  dsRequest.setRPCManager(rpcManager);
              } else {
                  prepareRequest(dsRequest, requestContext);
                  if (dsTransaction != null) {
                      dsRequest.setDSTransaction(dsTransaction);
                      if (userID != null && dsTransaction.getUserId() == null) {
                          dsTransaction.setUserId(userID.toString());
                          dsTransaction.setClientRequest(false);
                      }
                  } else if (dsTransaction == null) {
                      if (userID != null) {
                          dsRequest.setUserId(userID.toString());
                          dsRequest.setClientRequest(false);
                      }
                  }
              }
          }
      Best regards
      Blama

      PS: I agree that it is difficult to say what should be copied. I call that method with different parameters being null already.
      So perhaps it is really the best if everyone decides what he or she needs of the parent request.
      Last edited by Blama; 15 Apr 2016, 14:09.

      Comment

      Working...
      X