Weasis - Passing custom arguments to Weasis from jnlp

767 views
Skip to first unread message

Diego Venâncio Marcílio

unread,
Jan 23, 2013, 7:32:35 AM1/23/13
to dcm...@googlegroups.com
Hello,

I'm starting Weasis successfully in my application via a dynamically generated JNLP. What I would like is to pass a custom argument to Weasis and set it as System.Property, just as I believe some Weasis settings are done, so I can access it through Weasis runtime and do some internal actions my applications needs, like relating a study in my DB, and so on.

I managed to do it when I start Weasis from eclipse.
Example: I write the following "Program arguments" in Run Configurations:
$dicom:get -l "/home/myUser/image_9118081578888301667.dcm"
pwlmMedicalReportID
=123

And then i changed the code a little bit in WeasisLauncher.java, starting in Line 391. I'm sure that this is a messy way to do it, but it did the job.

SwingUtilities.invokeLater(new Runnable() {

               
@Override
               
public void run() {
                    m_tracker
.open();
                   
Object commandSession = getCommandSession(m_tracker
                           
.getService());
                   
if (commandSession != null) {
                       
// execute the commands from main argv
                       
for (StringBuffer command : commandList) {
                            commandSession_execute
(commandSession, command);
                         
// beginning of my code
                           
String parameter = "pwlmMedicalReportID=";
                           
int index = command.indexOf(parameter);
                           
if (index != 1) {
                               
int subStringIndex = index + parameter.length();
                               
String value = command
                                       
.substring(subStringIndex);
                               
System.setProperty("pwlmMedicalReportID",
                                        value
);
                           
}
                           
// end of my code
                       
}
                        commandSession_close
(commandSession);
                   
}

I first tried to pass arguments like: -VMPpwlmMedicalReportID but no success.

But I can't figure much as how the WebstartLauncher parse arguments. Some struggle with the code and java console gave me a clue that Felix is doing this, but I doesn't have a clue about Felix.
My ideal scenario would be something like this: (End of my JNLP)
<!-- Main class -->
   
<application-desc main-class="org.weasis.launcher.WebstartLauncher">
     
<!-- Example for opening dicom files from URLs -->
     
<argument>$dicom:get -l #{param.studyURL}</argument>
     
<argument>-VMPpwlmMedicalReportID="#{param.pwlmMedicalReportID}"</argument>
   
</application-desc>

Sorry for the trouble, as I'm really basically doing all the job by trial and error.  

Thanks in advance,
Diego.

nicolas...@gmail.com

unread,
Jan 25, 2013, 1:58:41 AM1/25/13
to dcm...@googlegroups.com
weasis-pacs-connector does not allow yet to add dynamically new properties, but you can use JNLP-Builder servlet and make a request that looks like that:
http://localhost:8080/jnlp-builder/?cdb=/weasis&arg=$dicom:get+-w+http://localhost:8080/weasis-pacs-connector/manifest?studyUID=numberStudyUID&arg=-VMPpwlmMedicalReportID=123
In the URL, the xml manifest is called through the weasis-pacs-connector servlet.

Otherwise, you can try to modify weasis-pacs-connector to accept new properties in parameters.

Diego Venâncio Marcílio

unread,
Feb 1, 2013, 3:07:23 PM2/1/13
to dcm...@googlegroups.com
Thanks for your answer.

I will assess the possibilities and post here if I find a solution.

Diego Venâncio Marcílio

unread,
Feb 14, 2013, 1:30:05 PM2/14/13
to
Alright, the main problem was my lack of knowledge regarding Java Web Start.

Inserting the following in my JNLP should work:
<property name="pwlmMedicalReportID" value="#{param.pwlmMedicalReportID}" />

But as I found in JWS documentation:
For an untrusted application, system properties set in the JNLP file will only be set by Java Web Start if they are considered secure, or if the property name begins with "jnlp." or "javaws.".
 
So the solution was changing the property name in JNLP:
<property name="javaws.pwlmMedicalReportID" value="#{param.pwlmMedicalReportID}" />

The property can be read in Weasis by the following java code:
String property = System.getProperty("javaws.pwlmMedicalReportID");

The downside, and I'm not really sure that this is caused by my new property, is that JavaWebStart is not using JARs compressed by pack200. It's looking for *.jar, when before it was looking for *.jar.pack.gz . I'll search more into that.

nicolas...@gmail.com

unread,
Feb 14, 2013, 5:13:01 PM2/14/13
to
Yes, if you build by our own the jnlp file you can simply add the property.

However, it is better to pass the property in the argument as in this jnlp file
<argument>-VMPpwlmMedicalReportID="#{param.pwlmMedicalReportID}"</argument>
It is a workaround to bypass this security restriction: http://java.dzone.com/articles/webstart-changes-6u17-until
Reply all
Reply to author
Forward
0 new messages