[RFC][icedtea-web] Fix for single instance service with applets using jnlp_href

Danesh Dadachanji ddadacha at redhat.com
Thu Aug 23 13:31:48 PDT 2012


On 17/05/12 02:53 PM, Danesh Dadachanji wrote:
>
>
> On 20/04/12 05:32 AM, Jiri Vanek wrote:
>>>>
>>>
>>> Yeah, it was a confusing service to wrap my head around. :S
>>>
>>> Right now, SingleInstanceService is available to use from applets/applications run by javaws. I am
>>> trying to port this over to the plugin so that when jnlp_href is used, applets have access to it.
>>>
>>> The point of the service itself is to only let one instance of an applet run at a time. There's a
>>> catch to running another instance of the applet though. While the first one is running, it is setup
>>> with a listener for later instances to use. The idea is that the second instance can communicate
>>> with the running instance, passing along some args to be handled by the listener, and then exit.
>>> When you run another instance of the applet, icedtea-web is supposed to recognize this as the second
>>> instance and pass on a list of arguments provided by the dev. See the API for
>>> SingleInstanceListener[1] for the methods. I think the following signleapp example[2] might help you
>>> too.
>>>
>>> Here's an example run path:
>>>
>>> 1. Start single instance app. The dev has set it up to handle params accordingly, say to spit it out
>>> on the screen to log.
>>> 2. IcedTea-Web sets up a single instance server to keep track of the instance running.
>>> 3. The second app is run, args are passed in by the dev again. Let's say they are the current
>>> date/time.
>>> 4. IcedTea-Web notices the second app is a second instance of the first one and checks that the
>>> first one's server is still running, then denies init of the second applet. The second instance's
>>> args are taken and passed along to the first instance's newActivation(String[] args) method.
>>> 5. Dev's newActivation method reacts accordingly.
>>>
>>> I hope the example[2] helps clear up any doubts I have not covered but please ask if it doesn't!
>>>
>>>>> Attached is a patch to fix SingleInstanceService to work when applets
>>>>> use jnlp_href.
>>>>>
>>>>> If a single instance exists, it'll throw a fatal exception for the
>>>>> second applet and stop running it. The applet passes the args along
>>>>> while checking. However, proprietary documentation is unclear about
>>>>> which args are passed so for now I have left it as a FIXME until
>>>>> that's cleared up.
>>>> I believe applets parameters inside tag/jnlp descriptor are correct way.
>>>
>>> These args I was referring to are from the second instance being run so we're talking about
>>> different things here. =) Please see above.
>>>
>> Well well... It was digging to find what this should be doing, and it looks tome like it is not doing something.
>>
>> Can I ask for large set of reproducers?
>>
>> two same javaws applications runnig together/ two same javaws applications running as SingleInstance and passing params / two different
>> javaws running together/ two different javaws applications running as SingleInstance and "passing" params
>>
>> two same applets-in-javaws applications runig together/ two same applets-in-javaws applications running as SingleInstance and passing
>> params / two different applets-in-javaws running together/ two different applets-in-javaws applications running as SingleInstance and
>> "passing" params
>>
>> two same applets-in-browser running together/ two same applets-in-javaws applications running as SingleInstance and passing params /two
>> different applets-in-browser running together/ two different applets-in-javaws applications running as SingleInstance and "passing"
>> params
>>
>>
>
> Could you elaborate more on the purpose of "two same javaws applications running together"? Similarly for the "applets-in-browser" and
> "applets-in-javaws" ones. As I understand it, these are just normal runs without SingleInstance, right? How is this related to the patch?
>
>>
>> It will need similar approach as I have used in xfork test, but better then sleep use StdOut use contentReader listeners and do not
>> wait for timeout (as it really delays test runs)
>>
>
> I'm not sure how this would be run in the current engine. We need to ensure both apps (for each test) are running at the same time. I
> don't think there is a way to guarantee this, is there? I know the tests are run one after another but they are only ordered
> alphabetically right? There is no way to specify I want to run test X and then immediately after run test Y (while test X is still
> running), is there?
>
>>
>> The patch itself looks ok, and if will pass above tests, then it is ok for head. The only issue is passing params to applet. Yes,
>
> By param you mean through SingleInstance, not through <param> tags right?
>
>> specification is silent in this issue, but I'm against String[0] (at least it is hard to test!:)). My idea here is to pass new
>> String{key1,value1, key2,value2...keyn,valuen}. Better then nothing I believe.
>>
>
> Would you mind elaborating on this some more too? I don't understand what the String{key,value,...} is meant to be.
>
>> Thanx for hard work!
>
> Thanks for the comments! Sorry for the long delay.

Hey all,

I ran out of time and couldn't get a chance to finish the reproducer for this patch. The tests are in place, all that needs doing is 
getting the 2 applets to run side by side. I couldn't figure out the magic for that. I'm posting it here in case anyone wants to pick 
it up again.

Here's the last ChangeLog I had (minus tests additions).

+2012-01-31  Danesh Dadachanji  <ddadacha at redhat.com>
+
+ Fixed SingleInstanceService to work with jnlp_href.
+ * netx/net/sourceforge/jnlp/Launcher.java
+ (launchApplication): Print existing single instance in debug mode.
+ (launchApplet): Added check for single instance, throws launchError if
+ single instance already exists.
+ (getApplet): Same as above.
+ (launchInstaller): Added TODO reminder for when it is implemented.
+ * netx/net/sourceforge/jnlp/resources/Messages.properties:
+ Added LSingleInstanceExists.
+ * netx/net/sourceforge/jnlp/services/XSingleInstanceService.java
+ (initializeSingleInstance): Modified to always initialize if the applet is
+ being run by the plugin.
+ (checkSingleInstanceRunning): Modified args passed to SingleInstanceListener.
+ Marked applets' args as FIXME, for now it passes an empty args array.
+

Regards,
Danesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: single-instance-service-02-pre.patch
Type: text/x-patch
Size: 22259 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20120823/1c067875/single-instance-service-02-pre.patch 


More information about the distro-pkg-dev mailing list