Adam Heath wrote:
Adam Heath wrote:
T result = Controller.runWith(data, new Callable<T>() {
    public T call() throws Exception {
        // code
        return null;
    }
});

I've actually attempted this, and while I think the implementation of
this pattern is simple, actually *using* it in higher-level code ends
up making things rather verbose.

I just added your idea to the branch, and it *is* simple. Let's say we want to make incoming requests a security-aware artifact:

org.ofbiz.webapp.control.ControlServlet

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
ThreadContext.runExecutionArtifact(new RequestArtifact(request, response));
    } catch (Throwable t) {
        // Do something with t
    }
}

public class RequestArtifact implements ExecutionArtifact {
...
}

Reply via email to