Say Scheveningen

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

3 responses so far ↓

  • Stephane // August 20, 2009 at 12:36 pm

    Hi Say,

    I’ve spent a lot oftime trying to get this work but can’t. I keep getting ClassCastException. I think I’ve tried all. I’ve tried having a minimal DFS library set, setting it as sandbox … then not sandbox… then trying to identify which JBoss internal jars may have some side-effect on those brought by the DFS. No luck, I’ve spent so much time on this that I was wondering if it would be possible to get some simple Composer project on either 6.0 or 6.5 that would implement what you suggest. I would be SSOOO thankful if you could provide me such a project.

    Best regards,

    Stephane

  • donr7n // August 21, 2009 at 9:28 am

    Stephane

    I have passed on your request and we’ll see what we can do.

    Don

  • Stephane // September 4, 2009 at 2:27 pm

    Hi Don,

    Did you by any chance find some time to have a look at my request?

    Thanks

    Stephane

Leave a Comment