Sometimes you want to invoke DFS services from within a Java Method Server method implementation.
First you should understand how to implement a method as a BOF module.
What remains is to package your module correctly for DFS service invocation. In order to do this we suggest the following:
- Create a sandboxed Java library containing the minimum classpath for your chosen DFS client, as described in the DFS SDK doc. This library can be included in all method modules that invoke DFS services.
- Create a sandboxed Java library containing your generated client classes for each service that you consume. Each library can be included in all method modules that invoke the corresponding DFS service. If you only have one or two methods then these classes could be folded into your implementation jar instead.
- Create an implementation jar for your method implementation.
Be sure that your method implementation observes the correct thread context class loader handling and you should be good to go. Here’s a little base class that takes care of that for you (note that this class must be in either your implementation jar or a sandboxed java library or it just won’t work).
package com.emc.examples;
import com.documentum.fc.client.DfSingleDocbaseModule;
import java.util.Map;
import java.io.PrintWriter;
public abstract class AbstractMethod extends DfSingleDocbaseModule implements IDfMethod
{
public final int execute(Map parameters, PrintWriter writer) throws Exception {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
ClassLoader moduleLoader = AbstractMethod.class.getClassLoader();
Thread.currentThread().setContextClassLoader(moduleLoader);
return doMethod(parameters, writer);
}
finally {
Thread.currentThread().setContextClassLoader(tccl);
}
}
public abstract int doMethod(Map parameters, PrintWriter writer) throws Exception;
}