Writing Custom Code — Your Code, Our Cloud
Posted on August 26, 2012 by Ajay Tiwari
public class MyCustomCode implements Executor { /** * Write your custom code inside this method */ @Override public HttpResponseObject execute(HttpRequestObject request) { JSONObject body = request.getBody(); // Build Log Service For logging in Your Code LogService logger = sp.buildLogService(); logger.debug(" Recieved Request Body : :" + body.toString(), moduleName); // Write Your Custom Code Here // ..............// logger.info("Running Custom Code ", moduleName); // Create JSON Response Based on Your business logic JSONObject jsonResponse = new JSONObject(); jsonResponse.put("status", "success"); // Return JSON Response and Status Code // ..............// return new HttpResponseObject(HTTP_STATUS_SUCCESS, jsonResponse); }
Coming Soon...
NSString *username = @"Nick"; NSString *deviceToken = @"0213c473a389687c6094a5b6d445c0fbf27dca069e2c7ff9be979exxxxxxxxxx"; PushNotification *pushNotification = [pushnotificationService storeDeviceToken:username:deviceToken];
String nameOfCustomCodeService = "HelloWorld"; String jarFilePath = "D:\\myapps\\HelloWorld.jar"; ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); CustomCodeService customCodeService = api.buildCustomCodeService(); String jsonResponse = customCodeService.deployJarFile(nameOfCustomCodeService, jarFilePath);
Coming Soon...
String nameOfCustomCodeService = "HelloWorld"; JSONObject jsonBody = new JSONObject(); jsonBody.put("name", "John"); jsonBody.put("age", "30"); ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); CustomCodeService customCodeService = api.buildCustomCodeService(); JSONObject jsonResponse = customCodeService.runJavaCode(nameOfCustomCodeService, jsonBody);
String nameOfCustomCodeService = "HelloWorld"; JObject jsonBody = new JObject(); jsonBody.Add("name", "John"); jsonBody.Add("age", "30"); App42Callback requestCallback = this; /* This function used the App42Callback interface */ ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); CustomCodeService customCodeService = api.BuildCustomCodeService(); customCodeService.RunJavaCode(nameOfCustomCodeService, jsonBody, requestCallback); OnSuccess(Object obj) { JObject json = (JObject) obj; String jsonResponse = JObject.ToString(); } public class CallBack : App42Callback { public override void OnSuccess(Object obj) { JObject json = (JObject) obj; //Do whatever you want with the object } public override void OnException(App42Exception e) { //Do whatever you want with the exception } }
String nameOfCustomCodeService = "HelloWorld"; JSONObject jsonBody = new JSONObject(); jsonBody.put("name", "John"); jsonBody.put("age", "30"); ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); CustomCodeService customCodeService = api.buildCustomCodeService(); JSONObject jsonResponse = customCodeService.runJavaCode(nameOfCustomCodeService, jsonBody);
String nameOfCustomCodeService = "HelloWorld"; JSONObject jsonBody = new JSONObject(); jsonBody.put("name", "John"); jsonBody.put("age", "30"); ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); CustomCodeService customCodeService = api.buildCustomCodeService(); JSONObject jsonResponse = customCodeService.runJavaCode(nameOfCustomCodeService, jsonBody);
String nameOfCustomCodeService = "HelloWorld"; JObject jsonBody = new JObject(); jsonBody.Add("name", "John"); jsonBody.Add("age", "30"); ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>"); CustomCodeService customCodeService = api.BuildCustomCodeService(); JObject jsonResponse = customCodeService.RunJavaCode(nameOfCustomCodeService, jsonBody);