Can we override existing method of out-of-box handler in websphere commerce?

55 Views Asked by At

I want to add extra data into response entity of out of box handler method.

There is a out of box handler named CartHandler Which has below method

 @Path("@self/usable_payment_info")
 public Response getUsablePaymentInfo(@PathParam("storeId") @ParameterDescription(description="The store identifier.", valueProviderClass=StoreIdProvider.class, required=true) String storeId, @QueryParam("responseFormat") @ParameterDescription(description="The response format. If the request has an input body, that body must also use the format specified in \"responseFormat\". Valid values include \"json\" and \"xml\" without the quotes. If the responseFormat isn't specified, the \"accept\" HTTP header shall be used to determine the format of the response. If the \"accept\" HTTP header isn't specified as well, the default response format shall be in json.", valueProviderClass=ResponseType.class) String responseFormat, @QueryParam("pageNumber") @ParameterDescription(description="Page number, starting at 1. Valid values include positive integers of 1 and above. The \"pageSize\" must be specified for paging to work.") int pageNumber, @QueryParam("pageSize") @ParameterDescription(description="Page size. Used to limit the amount of data returned by a query. Valid values include positive integers of 1 and above. The \"pageNumber\" must be specified for paging to work.") int pageSize)
  {

  }

Now, i want to add extra fields to the existing json data which is generated in response of this above method.

So i tried to extend the CartHandler with in new handler which overrides the above method.


public class UsablePaymentInfoHandler extends CartHandler {

 @override
 public Response getUsablePaymentInfo(@PathParam("storeId") @ParameterDescription(description="The store identifier.", valueProviderClass=StoreIdProvider.class, required=true) String storeId, @QueryParam("responseFormat") @ParameterDescription(description="The response format. If the request has an input body, that body must also use the format specified in \"responseFormat\". Valid values include \"json\" and \"xml\" without the quotes. If the responseFormat isn't specified, the \"accept\" HTTP header shall be used to determine the format of the response. If the \"accept\" HTTP header isn't specified as well, the default response format shall be in json.", valueProviderClass=ResponseType.class) String responseFormat, @QueryParam("pageNumber") @ParameterDescription(description="Page number, starting at 1. Valid values include positive integers of 1 and above. The \"pageSize\" must be specified for paging to work.") int pageNumber, @QueryParam("pageSize") @ParameterDescription(description="Page size. Used to limit the amount of data returned by a query. Valid values include positive integers of 1 and above. The \"pageNumber\" must be specified for paging to work.") int pageSize)
  {
      super.getUsablePaymentInfo(storeId, responseFormat, pageNumber, pageSize);
      return null;
  }

}

But when i checked in debug mode, i found that control is not passed here as it is passing control to old out-of-box method only.

Can anyone suggest solution for this?

0

There are 0 best solutions below