Say Scheveningen

Entries categorized as ‘methodserver’

Writing Java server methods that invoke DFS services

May 20, 2009 · 3 Comments

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:

  1. 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.
  2. 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.
  3. 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;
}

Categories: dfs · methodserver

Implementing Java server methods as BOF modules

October 20, 2008 · 5 Comments

There are a couple of reasons you might want to deploy Java server methods as BOF modules.

  • You want to deploy the implementation in the same dar/docapp as the dm_method definition
  • You want to avoid jar hell by avoiding the java_methods directory
  • You want hot deployment for your method implementation

In order to deploy your method as a module you have to do the following:

  • Define a module by subclassing DfSingleDocbaseModule or have your module implement the marker interface IDfModule directly
  • Have your module implement IDfMethod – not IDmMethod (no interface jar)
  • Put the module name – not the class name – in the command_verb of the dm_method object
  • Make your module self-contained. You have no visibility to classes in the java_methods directory so you must be able to find anything you need in one or more BOF modules.

That’s it.

Categories: bof · methodserver

Method server class loaders

October 16, 2008 · 2 Comments

The method server has a unique class loader arrangement because it has it’s own load directory (java_methods) and also allows for methods to be written and deployed as BOF modules. The following diagram illustrates the method server class loader configuration.

Categories: methodserver