Page tree
Skip to end of metadata
Go to start of metadata

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

  • GET

Parameters:

  • databaseName(String databaseName): name of the database to read data from, use "server!!path/database.nsf" format; when omitted, current database is used
  • javaClass(String className): fully qualified class name; mandatory.

 

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.