Calling the applet from Javascript

Post here questions and problems related to oXygen frameworks/document types.
sderrick
Posts: 219

Calling the applet from Javascript

Sat May 30, 2015 5:48 pm

I'm having intermittent crashes when calling the applet to load up a file and am sure its something I'm not doing right.

I see two different methods used..

this one elevates privileges

Code: Select all

 public String getSerializedDocument() {
        //EXM-27477 This method might come from Javascript code, elevate privileges.
        return AccessController.doPrivileged(new PrivilegedAction<String>() {
            @Override
            public String run() {
                StringBuilder builder = new StringBuilder();
                BufferedReader reader = new BufferedReader(editorComponent
   


this one calls runnable, elevates privileges and waits on a thread.

Code: Select all

   public void setDocumentContent(final String url, final String xmlContent)
            throws AuthorComponentException {
        documentURL = url;
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                //EXM-27477 This method might come from Javascript code, elevate privileges.
                AccessController.doPrivileged(new PrivilegedAction<String>() {
                    @Override
                    public String run() {
                        invokeOnAWT(new Runnable() {
                            @Override
                            public void run() {


1.) Why the difference?

2.) If I add a function which should I use?

3.) If I return a value there is no built in thread accessors?

4.) What happens if these get stacked? elevate, calls another elevate?

thanks,

Scott
sderrick
Posts: 219

Re: Calling the applet from Javascript

Tue Jun 02, 2015 1:33 am

I cleaned up and combined the function calls into the applet from javascript, and so far that has ended the odd crash.

Though I haven't been able to run the applet from a remote server yet to really test it. It did appear to be timing or thread issues..

Scott
Radu
Posts: 5692

Re: Calling the applet from Javascript

Tue Jun 02, 2015 10:56 am

Hi Scott,

I am not sure why those crashes occurred, did you find any meaningful information in the Java console view?
From what I remember, when the Javascript code calls the applet code, it calls it with restrictive security permissions so we elevated the rights in the Java code.
An alternative to elevating the rights in the Java functions called from JS would have been to call System.setSecurityManager(null); early when the applet was started.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
sderrick
Posts: 219

Re: Calling the applet from Javascript

Tue Jun 02, 2015 3:57 pm

Radu,

When it happened, The browser would hang, no output in the console. When it would finally recover the console would close, and the web page would report the plugin had crashed.

If it happens again I will enable logging in the java control panel.

Scott

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests