package com.stanfy.utils;

import android.content.Context;
import android.content.Intent;

import com.stanfy.app.beans.BeansManager;
import com.stanfy.app.service.ApplicationService;
import com.stanfy.serverapi.request.RequestDescription;

/**
 * Requests performer for the server side.
 * @author Roman Mazur (Stanfy - http://www.stanfy.com)
 */
public class ServiceRequestPerformer implements RequestExecutor  {

  /** Application context. */
  private final Context context;

  public ServiceRequestPerformer(final Context a) {
    this.context = a.getApplicationContext();
  }

  @Override
  public int performRequest(final RequestDescription description) {
    Class<?> serviceClass = BeansManager.get(context).getRemoteServerApiConfiguration().getApplicationServiceClass();
    context.startService(
        new Intent(context, serviceClass)
        .setAction(ApplicationService.ACTION_SEND_REQUEST)
        .putExtra(ApplicationService.EXTRA_REQUEST_DESCRIPTION, description)
    );
    return description.getId();
  }

}

@@ -675,24 +675,194 @@
 ription) %7B%0D%0A
+    context.startService(constructIntent(description));%0D%0A    return description.getId();%0D%0A  %7D%0D%0A%0D%0A  public Intent constructIntent(final RequestDescription description) %7B%0D%0A
     Class%3C?%3E
@@ -976,38 +976,14 @@
     
-context.startService(%0D%0A       
+return
  new
@@ -1154,48 +1154,8 @@
 ion)
-%0D%0A    );%0D%0A    return description.getId()
 ;%0D%0A 

make it possible to construct intent required for starting request processing