Available since Beta-5

Use this strategy to reuse your existing java classes or to write specific methods/workflows/processes that SmartNSF does not provide..

Allowed method

Parameters:

 

router.GET('info') {
 strategy(CUSTOM) {
   javaClass('org.openntf.rest.MyCustomStrategy')
 }

 

Your custom class has to implement CustomRestHandler interface.

package org.openntf.smartnsf;

import org.openntf.xrest.xsp.exec.Context;
import org.openntf.xrest.xsp.exec.CustomRestHandler;

import com.ibm.commons.util.io.json.JsonJavaObject;
import com.ibm.commons.util.io.json.util.JsonWriter;

public class MyRestHandler implements CustomRestHandler {

        public void processCall(Context context, String path) throws Exception {

                System.out.println("Was Called");
                JsonJavaObject result = new JsonJavaObject();
                result.put("test", "hello");
                JsonWriter jsw = new JsonWriter(context.getResponse().getWriter(),true);
                jsw.outObject(result);
                jsw.close();
        }

}

 

 

Returned JSON depends on what your class returns.

 

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.

Related issues