Difference between revisions of "Using the CTP Application Server"

From MircWiki
Jump to navigation Jump to search
 
(43 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This article describes how to use the CTP Application Server to download and launch Java applications using the Java Web Start protocol (JNLP).
 
This article describes how to use the CTP Application Server to download and launch Java applications using the Java Web Start protocol (JNLP).
  
The CTP Application Server is a servlet that is included in all CTP versions starting with 2012/08/15. The servlet is accessed through the URL <tt><b>/webstart/{name}</b></tt>, where {name} is the name of the application program to be launched.
+
Java Web Start allows Java programs to be run from a server without being installed on the client. The download is started by accessing a resource on the server through a browser. The resource is an XML structure that is served to the browser with the content type <tt><b>application/x-java-jnlp-file</b></tt>. The XML provides all the necessary information to allow Java to import the program and any resources it needs from the server and run it on  the client with the necessary security constraints.
  
To deploy a Java program for downloading by the Application Server servlet, the program and all the resources it uses (jar libraries, etc.) must be placed in a first-generation child directory of CTP/ROOT. An XSL file with the name {name}.xsl must also appear in the same directory. The XSL file is used by the servlet to process a dynamically generated XML document and produce the JNLP XML structure required to trigger the download and launch of the application.
+
The simplest way to launch a Web Start application from the CTP server is to put the JNLP XML file, the program, and all the resources it requires in the <tt><b>CTP/ROOT</b></tt> directory or in one of its subdirectories. The program is launched simply by accessing the JNLP XML file, which must have the extension <tt><b>.jnlp</b></tt>. For example, if the JNLP XML file is located at <tt><b>CTP/ROOT/apps/MyApp.jnlp</b></tt>, the URL path would be <tt><b>/apps/MyApp.jnlp</b></tt>. In this method, it is not possible to supply parameters to the program dynamically.
 +
 +
The CTP Application Server is a servlet that is included in all CTP versions starting with 2012/08/15. The servlet is accessed through the URL <tt><b>/webstart/{name}</b></tt>, where {name} is the name of the application program to be launched. The purpose of the Application Server is to allow arguments to be supplied to the program from query parameters in the request.
 +
 
 +
To deploy a Java program for downloading by the Application Server servlet, the program and all the resources it uses (jar libraries, etc.) must be placed in a child directory of <tt><b>CTP/ROOT</b></tt>. The name of the directory must be the same as the name of the application. For example, the CTPClient program and all its libraries must be placed in the <tt><b>CTP/ROOT/CTPClient</b></tt> directory.
 +
 
 +
An XSL file with the name {name}.xsl must also appear in the same directory. The XSL file is used by the servlet to process a dynamically generated XML document and produce the JNLP XML structure required to trigger the download and launch the application.
  
 
The structure of the dynamically generated document is:
 
The structure of the dynamically generated document is:
Line 14: Line 20:
 
     </environment>
 
     </environment>
 
     <params>
 
     <params>
         <{param1name}><![CDATA[{param1value}]]></{param1name}>
+
         <param><![CDATA[{param1name}={param1value}]]></param>
 
         etc.
 
         etc.
 
     </params>
 
     </params>
Line 20: Line 26:
 
</pre>
 
</pre>
  
The values of the elements in the document are constructed by the servlet from the HTTP connection. For example, to launch the TCIASender application, the URL might be:
+
The values of the elements in the document are constructed by the servlet from the HTTP request. For example, to launch the CTPClient application, the URL might be:
  
:<tt><b>http://nbia.somewhere.edu/webstart/TCIASender?title=My%20Institution&name=My%20Name
+
:<tt><b>http://nbia.somewhere.edu/webstart/CTPClient?title=My%20Institution&name=My%20Name</b></tt>
  
 
In this case, the document generated by the servlet will be:
 
In this case, the document generated by the servlet will be:
Line 30: Line 36:
 
         <protocol>http</protocol>
 
         <protocol>http</protocol>
 
         <host>nbia.somewhere.edu:80</host>
 
         <host>nbia.somewhere.edu:80</host>
         <application>TCIASender</application>
+
         <application>CTPClient</application>
 
     </environment>
 
     </environment>
 
     <params>
 
     <params>
         <title><![CDATA[My Institution]]></title>
+
         <param><![CDATA[title=My Institution]]></param>
         <name><![CDATA[My Name]]></name>
+
         <param><![CDATA[name=My Name]]></param>
 
     </params>
 
     </params>
 
</jnlp>
 
</jnlp>
 
</pre>
 
</pre>
  
The XSL program to launch the application would be:
+
The XSL program to launch this application would be <B><tt>CTP/ROOT/CTPClient/CTPClient.xsl</tt></b>:
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="iso-8859-1"?>
 
<?xml version="1.0" encoding="iso-8859-1"?>
Line 46: Line 52:
  
 
<xsl:template match="/jnlp">
 
<xsl:template match="/jnlp">
<jnlp
+
    <jnlp
codebase="{environment/protocol}://{environment/host}/{environment/application}" >
+
        codebase="{environment/protocol}://{environment/host}/{environment/application}" >
<!-- href="{environment/application}.jnlp" > -->
+
        <!-- href="{environment/application}.jnlp" > -->
 +
 
 +
        <information>
 +
            <title>CTP Client Utility</title>
 +
            <vendor>RSNA</vendor>
 +
            <homepage href="http://mircwiki.rsna.org//index.php?title=CTP-The_RSNA_Clinical_Trial_Processor"/>
 +
            <description>CTP Client Utility</description>
 +
            <description kind="short">Java Web Start program for transmitting data to CTP for clinical trials.</description>
 +
            <!-- <offline-allowed/> -->
 +
        </information>
  
<information>
+
        <security>
<title>TCIA Transport Utility</title>
+
            <all-permissions/>
<vendor>RSNA</vendor>
+
        </security>
<homepage href="http://mircwiki.rsna.org//index.php?title=CTP-The_RSNA_Clinical_Trial_Processor"/>
 
<description>TCIA Transport Utility</description>
 
<description kind="short">Java Web Start program for transmitting images to TCIA for clinical trials.</description>
 
<!-- <offline-allowed/> -->
 
</information>
 
  
<security>
+
        <resources>
<all-permissions/>
+
            <j2se version="1.6+"/>
</security>
+
            <jar href="CTPClient.jar"/>
 +
            <jar href="CTP.jar"/>
 +
            <jar href="dcm4che.jar"/>
 +
            <jar href="log4j.jar"/>
 +
            <jar href="util.jar"/>
 +
        </resources>
  
<resources>
+
        <application-desc main-class="client.CTPClient">
<j2se version="1.5+"/>
+
            <argument>"protocol=<xsl:value-of select="environment/protocol"/>"</argument>
<jar href="TCIASender.jar"/>
+
            <argument>"host=<xsl:value-of select="environment/host"/>"</argument>
<jar href="CTP.jar"/>
+
            <argument>"application=<xsl:value-of select="environment/application"/>"</argument>
<jar href="dcm4che.jar"/>
+
            <xsl:apply-templates select="params/param"/>
<jar href="log4j.jar"/>
+
        </application-desc>
<jar href="util.jar"/>
+
    </jnlp>
</resources>
+
</xsl:template>
  
<application-desc main-class="tcia.TCIASender">
+
<xsl:template match="param">
<argument>"<xsl:value-of select="params/title"/>"</argument>
+
    <argument>"<xsl:value-of select="."/>"</argument>
<argument>"<xsl:value-of select="params/name"/>"</argument>
 
</application>
 
</jnlp>
 
 
</xsl:template>
 
</xsl:template>
  
Line 83: Line 95:
  
 
Notes:
 
Notes:
*If the <tt><b>&lt;all-permissions/&gt;</b></tt> element is included, all the jars listed in the <tt><b>&lt;resources/&gt;</b></tt> element must be signed.
+
*The arguments supplied to the application will all have the form:
*This method of launching the application does not support its being launched by the Java Application Manager off-line because there is no JNLP file available on the disk.
+
*: "{paramname}={paramvalue}"
 +
*This program automatically supplies the host domain name and the application name as arguments.
 +
*The <b><tt>&lt;j2se&gt;</tt></b> element has the optional <b><tt>max-heap-size</tt></b> attribute. This can be used to assign the application more than the default memory allocation. The value of the attribute is specified like the Java <b><tt>-Xmx</tt></b> parameter (e.g., <b><tt>max-heap-size="768m"</tt></b>).
 +
*If the <tt><b>&lt;all-permissions/&gt;</b></tt> element is included, all the jars listed in the <tt><b>&lt;resources&gt;</b></tt> element must be signed by the same certificate. (If libraries signed by other certificates are required, they can be re-signed by the common certificate or they can be referenced by <tt><b>&lt;extension&gt;</b></tt> elements that point to separate JNLP files.)
 +
*This method of launching the application does not support its being launched by the Java Application Manager off-line because there is no JNLP file available on the disk. Thus the <tt><b>href</b></tt> attribute of the <tt><b>&lt;jnlp&gt;</b></tt> element must not be generated by the XSL. Doing so will cause the Application Manager to attempt to download the JNLP file, and when that access fails, it will refuse to launch the application.

Latest revision as of 13:40, 9 September 2015

This article describes how to use the CTP Application Server to download and launch Java applications using the Java Web Start protocol (JNLP).

Java Web Start allows Java programs to be run from a server without being installed on the client. The download is started by accessing a resource on the server through a browser. The resource is an XML structure that is served to the browser with the content type application/x-java-jnlp-file. The XML provides all the necessary information to allow Java to import the program and any resources it needs from the server and run it on the client with the necessary security constraints.

The simplest way to launch a Web Start application from the CTP server is to put the JNLP XML file, the program, and all the resources it requires in the CTP/ROOT directory or in one of its subdirectories. The program is launched simply by accessing the JNLP XML file, which must have the extension .jnlp. For example, if the JNLP XML file is located at CTP/ROOT/apps/MyApp.jnlp, the URL path would be /apps/MyApp.jnlp. In this method, it is not possible to supply parameters to the program dynamically.

The CTP Application Server is a servlet that is included in all CTP versions starting with 2012/08/15. The servlet is accessed through the URL /webstart/{name}, where {name} is the name of the application program to be launched. The purpose of the Application Server is to allow arguments to be supplied to the program from query parameters in the request.

To deploy a Java program for downloading by the Application Server servlet, the program and all the resources it uses (jar libraries, etc.) must be placed in a child directory of CTP/ROOT. The name of the directory must be the same as the name of the application. For example, the CTPClient program and all its libraries must be placed in the CTP/ROOT/CTPClient directory.

An XSL file with the name {name}.xsl must also appear in the same directory. The XSL file is used by the servlet to process a dynamically generated XML document and produce the JNLP XML structure required to trigger the download and launch the application.

The structure of the dynamically generated document is:

<jnlp>
    <environment>
        <protocol>http[s]</protocol>
        <host>{ip:port}</host>
        <application>{appname}</application>
    </environment>
    <params>
        <param><![CDATA[{param1name}={param1value}]]></param>
         etc.
    </params>
</jnlp>

The values of the elements in the document are constructed by the servlet from the HTTP request. For example, to launch the CTPClient application, the URL might be:

http://nbia.somewhere.edu/webstart/CTPClient?title=My%20Institution&name=My%20Name

In this case, the document generated by the servlet will be:

<jnlp>
    <environment>
        <protocol>http</protocol>
        <host>nbia.somewhere.edu:80</host>
        <application>CTPClient</application>
    </environment>
    <params>
        <param><![CDATA[title=My Institution]]></param>
        <param><![CDATA[name=My Name]]></param>
    </params>
</jnlp>

The XSL program to launch this application would be CTP/ROOT/CTPClient/CTPClient.xsl:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" />

<xsl:template match="/jnlp">
    <jnlp
        codebase="{environment/protocol}://{environment/host}/{environment/application}" >
        <!-- href="{environment/application}.jnlp" > -->

        <information>
            <title>CTP Client Utility</title>
            <vendor>RSNA</vendor>
            <homepage href="http://mircwiki.rsna.org//index.php?title=CTP-The_RSNA_Clinical_Trial_Processor"/>
            <description>CTP Client Utility</description>
            <description kind="short">Java Web Start program for transmitting data to CTP for clinical trials.</description>
            <!-- <offline-allowed/> -->
        </information>

        <security>
            <all-permissions/>
        </security>

        <resources>
            <j2se version="1.6+"/>
            <jar href="CTPClient.jar"/>
            <jar href="CTP.jar"/>
            <jar href="dcm4che.jar"/>
            <jar href="log4j.jar"/>
            <jar href="util.jar"/>
        </resources>

        <application-desc main-class="client.CTPClient">
            <argument>"protocol=<xsl:value-of select="environment/protocol"/>"</argument>
            <argument>"host=<xsl:value-of select="environment/host"/>"</argument>
            <argument>"application=<xsl:value-of select="environment/application"/>"</argument>
            <xsl:apply-templates select="params/param"/>
        </application-desc>
    </jnlp>
</xsl:template>

<xsl:template match="param">
    <argument>"<xsl:value-of select="."/>"</argument>
</xsl:template>

</xsl:stylesheet>

Notes:

  • The arguments supplied to the application will all have the form:
    "{paramname}={paramvalue}"
  • This program automatically supplies the host domain name and the application name as arguments.
  • The <j2se> element has the optional max-heap-size attribute. This can be used to assign the application more than the default memory allocation. The value of the attribute is specified like the Java -Xmx parameter (e.g., max-heap-size="768m").
  • If the <all-permissions/> element is included, all the jars listed in the <resources> element must be signed by the same certificate. (If libraries signed by other certificates are required, they can be re-signed by the common certificate or they can be referenced by <extension> elements that point to separate JNLP files.)
  • This method of launching the application does not support its being launched by the Java Application Manager off-line because there is no JNLP file available on the disk. Thus the href attribute of the <jnlp> element must not be generated by the XSL. Doing so will cause the Application Manager to attempt to download the JNLP file, and when that access fails, it will refuse to launch the application.