O'Reilly logo

Resource-Oriented Computing with NetKernel by Tom Geudens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. DPML

Declarative-Request Process Markup Language (DPML) is a heavyweight name for a simple, lightweight language. It has a simple syntax to do one thing extremely well, resource request handling.

Glue

You’re probably wondering why you should learn yet another language, and one with a limited use, too. The chance you heard of DPML before you started with NetKernel is zero.

Remember the hello.dpml program from FirstModule?

<?xml version="1.0" encoding="UTF-8"?>
<sequence>
  <request assignment="response">
    <identifier>active:freemarker</identifier>
    <argument name="operator">
      <literal type="string">Input value: ${value}</literal>
    </argument>
    <argument name="value">arg:value</argument>
  </request>
  <log>
    <message>
     <literal type="string">DPML example running with input %1</literal>
    </message>
    <param>arg:value</param>
  </log>
</sequence>

The hello.groovy equivalent looks like this:

import org.netkernel.layer0.nkf.NKFException; import org.netkernel.layer0.nkf.INKFRequestReadOnly; value = context.source("arg:value", String.class); subrequest_url = "active:freemarker"; subrequest = context.createRequest(subrequest_url); subrequest.setVerb(INKFRequestReadOnly.VERB_SOURCE); subrequest.addArgumentByValue("operator",'Input value: ${value}'); subrequest.addArgumentByValue("value",value); subrequest.setRepresentationClass(String.class); resultString = context.issueRequest(subrequest); logString = context.formatRaw('DPML example running with input %1',value); context.logRaw(context.LEVEL_INFO,logString); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required