Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsJVMManager Struct Reference

#include <nsJVMManager.h>

Inheritance diagram for nsJVMManager:
Inheritance graph
[legend]
Collaboration diagram for nsJVMManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_AGGREGATED
NS_DECL_NSIJVMMANAGER
NS_DECL_NSIOBSERVER NS_IMETHOD 
GetCurrentThread (PRThread **threadID)
 Returns a unique identifier for the "current" system thread.
NS_IMETHOD Sleep (PRUint32 milli=0)
 Pauses the current thread for the specified number of milliseconds.
NS_IMETHOD EnterMonitor (void *address)
 Creates a unique monitor for the specified address, and makes the current system thread the owner of the monitor.
NS_IMETHOD ExitMonitor (void *address)
 Exits the monitor associated with the address.
NS_IMETHOD Wait (void *address, PRUint32 milli=0)
 Waits on the monitor associated with the address (must be entered already).
NS_IMETHOD Notify (void *address)
 Notifies a single thread waiting on the monitor associated with the address (must be entered already).
NS_IMETHOD NotifyAll (void *address)
 Notifies all threads waiting on the monitor associated with the address (must be entered already).
NS_IMETHOD CreateThread (PRThread **thread, nsIRunnable *runnable)
 Creates a new thread, calling the specified runnable's Run method (a la Java).
NS_IMETHOD PostEvent (PRThread *thread, nsIRunnable *runnable, PRBool async)
 Posts an event to specified thread, calling the runnable from that thread.
NS_IMETHOD StartupLiveConnect (JSRuntime *runtime, PRBool &outStarted)
 Attempts to start LiveConnect using the specified JSRuntime.
NS_IMETHOD ShutdownLiveConnect (JSRuntime *runtime, PRBool &outShutdown)
 Attempts to stop LiveConnect using the specified JSRuntime.
NS_IMETHOD IsLiveConnectEnabled (PRBool &outEnabled)
 Indicates whether LiveConnect can be used.
NS_IMETHOD InitLiveConnectClasses (JSContext *context, JSObject *globalObject)
 Initializes a JSContext with the proper LiveConnect support classes.
NS_IMETHOD WrapJavaObject (JSContext *context, jobject javaObject, JSObject **outJSObject)
 Creates a JavaScript wrapper for a Java object.
NS_IMETHOD GetClasspathAdditions (const char **result)
nsIJVMPluginGetJVMPlugin (void)
nsJVMStatus StartupJVM (void)
nsJVMStatus ShutdownJVM (PRBool fullShutdown=PR_FALSE)
nsJVMStatus GetJVMStatus (void)
void SetJVMEnabled (PRBool enabled)
nsresult AddToClassPath (const char *dirPath)
PRBool MaybeStartupLiveConnect (void)
PRBool MaybeShutdownLiveConnect (void)
PRBool IsLiveConnectEnabled (void)
JSJavaVMGetJSJavaVM (void)
 nsJVMManager (nsISupports *outer)
virtual ~nsJVMManager (void)
void createProxyJNI (in nsISecureEnv secureEnv, out JNIEnv outProxyEnv)
 Creates a proxy JNI with an optional secure environment (which can be NULL).
void getProxyJNI (out JNIEnv outProxyEnv)
 Returns the proxy JNI associated with the current thread, or NULL if no such association exists.
void showJavaConsole ()
 Called from Java Console menu item.
boolean isAllPermissionGranted (in string lastFingerprint, in string lastCommonName, in string rootFingerprint, in string rootCommonName)
 isAllPermissionGranted [Deprecated Sep-10-2000]
nsIPrincipal isAppletTrusted (in string aRSABuf, in PRUint32 aRSABufLen, in string aPlaintext, in PRUint32 aPlaintextLen, out boolean isTrusted)
 isAppletTrusted
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Static Public Member Functions

static NS_METHOD Create (nsISupports *outer, const nsIID &aIID, void **aInstancePtr)

Public Attributes

readonly attribute boolean JavaEnabled
 The JavaEnabled variable to see if Java is Enabled or not.

Protected Member Functions

nsresult GetChrome (nsIWebBrowserChrome **theChrome)
const char * GetJavaErrorString (JRIEnv *env)

Protected Attributes

nsIJVMPluginfJVM
nsJVMStatus fStatus
nsISupports * fDebugManager
JSJavaVMfJSJavaVM
nsVoidArrayfClassPathAdditions
char * fClassPathAdditionsString
PRBool fStartupMessagePosted

Detailed Description

Definition at line 65 of file nsJVMManager.h.


Constructor & Destructor Documentation

nsJVMManager::nsJVMManager ( nsISupports *  outer)

Definition at line 368 of file nsJVMManager.cpp.

    : fJVM(NULL), fStatus(nsJVMStatus_Enabled),
      fDebugManager(NULL), fJSJavaVM(NULL),
      fClassPathAdditions(new nsVoidArray()), fClassPathAdditionsString(NULL),
      fStartupMessagePosted(PR_FALSE)
{
    NS_INIT_AGGREGATED(outer);

    nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
    if (branch) {
        branch->AddObserver("security.enable_java", this, PR_FALSE);
        PRBool prefBool = PR_TRUE;
        nsresult rv = branch->GetBoolPref("security.enable_java", &prefBool);
        if (NS_SUCCEEDED(rv)) {
            SetJVMEnabled(prefBool);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 387 of file nsJVMManager.cpp.

{
    int count = fClassPathAdditions->Count();
    for (int i = 0; i < count; i++) {
        PR_Free((*fClassPathAdditions)[i]);
    }
    delete fClassPathAdditions;
    if (fClassPathAdditionsString)
        PR_Free(fClassPathAdditionsString);
    if (fJVM) {
        /*nsrefcnt c =*/ fJVM->Release();   // Release for QueryInterface in GetJVM
        // XXX unload plugin if c == 1 ? (should this be done inside Release?)
    }
}

Member Function Documentation

Definition at line 1011 of file nsJVMManager.cpp.

{
    nsIJVMPlugin* jvm = GetJVMPlugin();

    /* Add any zip or jar files in this directory to the classpath: */
    PRDir* dir = PR_OpenDir(dirPath);
    if (dir != NULL) {
        PRDirEntry* dirent;
        while ((dirent = PR_ReadDir(dir, PR_SKIP_BOTH)) != NULL) {
            PRFileInfo info;
            char sep = PR_GetDirectorySeparator();
            char* path = PR_smprintf("%s%c%s", dirPath, sep, PR_DirName(dirent));
                     if (path != NULL) {
                     PRBool freePath = PR_TRUE;
                   if ((PR_GetFileInfo(path, &info) == PR_SUCCESS)
                       && (info.type == PR_FILE_FILE)) {
                       int len = PL_strlen(path);

                       /* Is it a zip or jar file? */
                       if ((len > 4) && 
                           ((PL_strcasecmp(path+len-4, ".zip") == 0) || 
                            (PL_strcasecmp(path+len-4, ".jar") == 0))) {
                           fClassPathAdditions->AppendElement((void*)path);
                           if (jvm) {
                               /* Add this path to the classpath: */
                               jvm->AddToClassPath(path);
                           }
                           freePath = PR_FALSE;
                       }
                   }
                   
                   // Don't leak the path!
                   if (freePath)
                          PR_smprintf_free(path);
               }
        }
        PR_CloseDir(dir);
    }

    /* Also add the directory to the classpath: */
    fClassPathAdditions->AppendElement((void*)dirPath);
    if (jvm) {
        jvm->AddToClassPath(dirPath);
        // jvm->Release(); // GetJVMPlugin no longer calls AddRef
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_METHOD nsJVMManager::Create ( nsISupports *  outer,
const nsIID aIID,
void **  aInstancePtr 
) [static]

Definition at line 349 of file nsJVMManager.cpp.

{
        if (!aInstancePtr)
                return NS_ERROR_INVALID_POINTER;
        *aInstancePtr = nsnull;

    if (outer && !aIID.Equals(kISupportsIID))
        return NS_ERROR_INVALID_ARG; 
    nsJVMManager* jvmmgr = new nsJVMManager(outer);
    if (jvmmgr == NULL)
        return NS_ERROR_OUT_OF_MEMORY;

        nsresult rv = jvmmgr->AggregatedQueryInterface(aIID, aInstancePtr);
        if(NS_FAILED(rv))
                delete jvmmgr;

        return rv;
}

Here is the call graph for this function:

void nsIJVMManager::createProxyJNI ( in nsISecureEnv  secureEnv,
out JNIEnv  outProxyEnv 
) [inherited]

Creates a proxy JNI with an optional secure environment (which can be NULL).

There is a one-to-one correspondence between proxy JNIs and threads, so calling this method multiple times from the same thread will return the same proxy JNI.

NS_METHOD nsJVMManager::CreateThread ( PRThread **  thread,
nsIRunnable runnable 
) [virtual]

Creates a new thread, calling the specified runnable's Run method (a la Java).

Implements nsIThreadManager.

Definition at line 287 of file nsJVMManager.cpp.

{
       PRThread* thread = PR_CreateThread(PR_USER_THREAD, &thread_starter, (void*) runnable,
                                                               PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
       *outThread = thread;
       return (thread != NULL ?  NS_OK : NS_ERROR_FAILURE);
}

Here is the call graph for this function:

NS_METHOD nsJVMManager::EnterMonitor ( void address) [virtual]

Creates a unique monitor for the specified address, and makes the current system thread the owner of the monitor.

Implements nsIThreadManager.

Definition at line 248 of file nsJVMManager.cpp.

{
       return (PR_CEnterMonitor(address) != NULL ? NS_OK : NS_ERROR_FAILURE);
}

Here is the caller graph for this function:

NS_METHOD nsJVMManager::ExitMonitor ( void address) [virtual]

Exits the monitor associated with the address.

Implements nsIThreadManager.

Definition at line 254 of file nsJVMManager.cpp.

{
       return (PR_CExitMonitor(address) == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE);
}

Here is the caller graph for this function:

nsresult nsJVMManager::GetChrome ( nsIWebBrowserChrome **  theChrome) [protected]
Returns:
conjure up THE nsIWebBrowserChrome instance from thin air!

Definition at line 784 of file nsJVMManager.cpp.

{
    *theChrome = nsnull;

    nsresult rv;
    nsCOMPtr<nsIWindowWatcher> windowWatcher =
        do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
    if (NS_FAILED(rv)) {
        return rv;
    }
    nsCOMPtr<nsIDOMWindow> domWindow;
    windowWatcher->GetActiveWindow(getter_AddRefs(domWindow));
    nsCOMPtr<nsIScriptGlobalObject> scriptObject =
        do_QueryInterface(domWindow, &rv);
    if (!scriptObject) {
        return rv;
    }
    nsIDocShell *docShell = scriptObject->GetDocShell();
    if (!docShell) {
        return NS_OK;
    }
    nsCOMPtr<nsPresContext> presContext;
    rv = docShell->GetPresContext(getter_AddRefs(presContext));
    if (!presContext) {
        return rv;
    }
    nsCOMPtr<nsISupports> container(presContext->GetContainer());
    nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(container, &rv);
    if (!treeItem) {
        return rv;
    }
    nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
    treeItem->GetTreeOwner(getter_AddRefs(treeOwner));

    nsCOMPtr<nsIWebBrowserChrome> chrome = do_GetInterface(treeOwner, &rv);
    *theChrome = (nsIWebBrowserChrome *) chrome.get();
    NS_IF_ADDREF(*theChrome);
    return rv;
}

Here is the call graph for this function:

Definition at line 471 of file nsJVMManager.cpp.

{
    if (fClassPathAdditionsString != NULL)
        PR_Free(fClassPathAdditionsString);
    int count = fClassPathAdditions->Count();
    char* classpathAdditions = NULL;
    for (int i = 0; i < count; i++) {
        const char* path = (const char*)(*fClassPathAdditions)[i];
        char* oldPath = classpathAdditions;
        if (oldPath) {
            char sep = PR_GetPathSeparator();
            classpathAdditions = PR_smprintf("%s%c%s", oldPath, sep, path);
            PR_Free(oldPath);
        }
        else
            classpathAdditions = PL_strdup(path);
    }
    fClassPathAdditionsString = classpathAdditions;
    *result = classpathAdditions;  // XXX need to convert to PRUnichar*
    return classpathAdditions ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Returns a unique identifier for the "current" system thread.

Implements nsIThreadManager.

Definition at line 234 of file nsJVMManager.cpp.

{
       *threadID = PR_GetCurrentThread();
       return NS_OK;
}

Here is the call graph for this function:

const char* nsJVMManager::GetJavaErrorString ( JRIEnv env) [protected]

Definition at line 208 of file nsJVMManager.h.

{ return fJSJavaVM; }

Here is the caller graph for this function:

Definition at line 190 of file nsJVMManager.h.

{ return fJVM; }

Here is the caller graph for this function:

Definition at line 843 of file nsJVMManager.cpp.

{
    return fStatus;
}

Here is the caller graph for this function:

void nsIJVMManager::getProxyJNI ( out JNIEnv  outProxyEnv) [inherited]

Returns the proxy JNI associated with the current thread, or NULL if no such association exists.

NS_METHOD nsJVMManager::InitLiveConnectClasses ( JSContext context,
JSObject globalObject 
) [virtual]

Initializes a JSContext with the proper LiveConnect support classes.

Implements nsILiveConnectManager.

Definition at line 447 of file nsJVMManager.cpp.

{
       return (JSJ_InitJSContext(context, globalObject, NULL) ? NS_OK : NS_ERROR_FAILURE);
}

Here is the call graph for this function:

boolean nsIJVMManager::isAllPermissionGranted ( in string  lastFingerprint,
in string  lastCommonName,
in string  rootFingerprint,
in string  rootCommonName 
) [inherited]

isAllPermissionGranted [Deprecated Sep-10-2000]

nsIPrincipal nsIJVMManager::isAppletTrusted ( in string  aRSABuf,
in PRUint32  aRSABufLen,
in string  aPlaintext,
in PRUint32  aPlaintextLen,
out boolean  isTrusted 
) [inherited]

isAppletTrusted

NS_IMETHOD nsJVMManager::IsLiveConnectEnabled ( PRBool outEnabled) [inline, virtual]

Indicates whether LiveConnect can be used.

Implements nsILiveConnectManager.

Definition at line 163 of file nsJVMManager.h.

    {
       outEnabled = IsLiveConnectEnabled();
       return NS_OK;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 893 of file nsJVMManager.cpp.

{
#if 0
// TODO: Get a replacement for LM_GetMochaEnabled. This is on Tom's list.
       if (LM_GetMochaEnabled()) {
              nsJVMStatus status = GetJVMStatus();
              return (status == nsJVMStatus_Enabled || status == nsJVMStatus_Running);
       }
#endif
       return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 882 of file nsJVMManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 851 of file nsJVMManager.cpp.

{
    if (fJSJavaVM)
        return PR_TRUE;

       do {
              static PRBool registeredLiveConnectFactory = NS_SUCCEEDED(JSJ_RegisterLiveConnectFactory());
        if (IsLiveConnectEnabled()) {
            JVM_InitLCGlue();
#if 0
            nsIJVMPlugin* plugin = GetJVMPlugin();
            if (plugin) {
                   const char* classpath = NULL;
                   nsresult err = plugin->GetClassPath(&classpath);
                   if (err != NS_OK) break;

                   JavaVM* javaVM = NULL;
                   err = plugin->GetJavaVM(&javaVM);
                   if (err != NS_OK) break;
#endif
                   fJSJavaVM = JSJ_ConnectToJavaVM(NULL, NULL);
                   if (fJSJavaVM != NULL)
                       return PR_TRUE;
                   // plugin->Release(); // GetJVMPlugin no longer calls AddRef
               //}
           }
       } while (0);
    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_METHOD nsJVMManager::Notify ( void address) [virtual]

Notifies a single thread waiting on the monitor associated with the address (must be entered already).

Implements nsIThreadManager.

Definition at line 267 of file nsJVMManager.cpp.

{
       return (PR_CNotify(address) == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE);
}
NS_METHOD nsJVMManager::NotifyAll ( void address) [virtual]

Notifies all threads waiting on the monitor associated with the address (must be entered already).

Implements nsIThreadManager.

Definition at line 273 of file nsJVMManager.cpp.

{
       return (PR_CNotifyAll(address) == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE);
}
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
NS_METHOD nsJVMManager::PostEvent ( PRThread thread,
nsIRunnable runnable,
PRBool  async 
) [virtual]

Posts an event to specified thread, calling the runnable from that thread.

Parameters:
threadIDthread to call runnable from
runnableobject to invoke from thread
asyncif true, won't block current thread waiting for result

Implements nsIThreadManager.

Definition at line 327 of file nsJVMManager.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIEventQueueService> eventService = 
             do_GetService(kEventQueueServiceCID, &rv);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIEventQueue> eventQueue = NULL;
    rv = eventService->GetThreadEventQueue(thread, getter_AddRefs(eventQueue));
    if (NS_FAILED(rv)) return rv;

    JVMRunnableEvent* runnableEvent = new JVMRunnableEvent(runnable);
    if (runnableEvent == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;
    if (async)
        eventQueue->PostEvent(runnableEvent);
    else
        eventQueue->PostSynchronousEvent(runnableEvent, nsnull);
    return rv;
}

Here is the call graph for this function:

Definition at line 769 of file nsJVMManager.cpp.

{
    if (enabled) {
        if (fStatus != nsJVMStatus_Running) 
            fStatus = nsJVMStatus_Enabled;
        // don't start the JVM here, do it lazily
    }
    else {
        if (fStatus == nsJVMStatus_Running) 
            (void)ShutdownJVM();
        fStatus = nsJVMStatus_Disabled;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Called from Java Console menu item.

Definition at line 748 of file nsJVMManager.cpp.

{
    if (fStatus == nsJVMStatus_Running) {
        PR_ASSERT(fJVM != NULL);
        // XXX need to shutdown JVM via ServiceManager
//        nsresult err = fJVM->ShutdownJVM(fullShutdown);
//        if (err == NS_OK)
            fStatus = nsJVMStatus_Enabled;
//        else {
//            ReportJVMError(err);
//            fStatus = nsJVMStatus_Disabled;
//        }
        fJVM = NULL;
    }
    PR_ASSERT(fJVM == NULL);
    return fStatus;
}

Here is the caller graph for this function:

NS_IMETHOD nsJVMManager::ShutdownLiveConnect ( JSRuntime runtime,
PRBool outShutdown 
) [inline, virtual]

Attempts to stop LiveConnect using the specified JSRuntime.

Implements nsILiveConnectManager.

Definition at line 153 of file nsJVMManager.h.

    {
       outShutdown = MaybeShutdownLiveConnect();
       return NS_OK;
    }

Here is the call graph for this function:

NS_METHOD nsJVMManager::Sleep ( PRUint32  milli = 0) [virtual]

Pauses the current thread for the specified number of milliseconds.

If milli is zero, then merely yields the CPU if another thread of greater or equal priority.

Implements nsIThreadManager.

Definition at line 241 of file nsJVMManager.cpp.

{
       PRIntervalTime ticks = (milli > 0 ? PR_MillisecondsToInterval(milli) : PR_INTERVAL_NO_WAIT);
       return (PR_Sleep(ticks) == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE);
}

Here is the call graph for this function:

Definition at line 616 of file nsJVMManager.cpp.

{
    // Be sure to check the prefs first before asking java to startup.
    switch (GetJVMStatus()) {
      case nsJVMStatus_Disabled:
        return nsJVMStatus_Disabled;
      case nsJVMStatus_Running:
        return nsJVMStatus_Running;
      default:
        break;
    }

#ifdef DEBUG
    PRIntervalTime start = PR_IntervalNow();
    if (NSJAVA == NULL)
        NSJAVA = PR_NewLogModule("NSJAVA");
    PR_LOG(NSJAVA, PR_LOG_ALWAYS, ("Starting java..."));
#endif

 /* TODO: Show the progress bar.
       MWContext* someRandomContext = XP_FindSomeContext();
       if (someRandomContext) {
              FE_Progress(someRandomContext, XP_GetString(XP_PROGRESS_STARTING_JAVA));
       }
 */

#ifdef MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    
    PRUintn uStatus=0;
    EnterMonitor(&uStatus);
#endif // MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    

    PR_ASSERT(fJVM == NULL);
    /*
    **TODO: amusil. Load the plugin by getting into Service manager.
    **              Right now there is no API to do this stuff. We need to
    **              add this to nsIPluginHost. We need a case where we just 
    **              load the plugin but do not instantiate any instance. 
    **              The code in there right now always creates a new instance.
    **              But for Java we may not create any instances and may need to
    **              do JNI calls via liveconnect.
    */

       // beard:  Now uses the nsIPluginHost to load the plugin factory for NS_JVM_MIME_TYPE.
    nsresult err;
    nsCOMPtr<nsIPluginHost> pluginHost = 
             do_GetService(kPluginManagerCID, &err);
    if (NS_FAILED(err)) {
        fStatus = nsJVMStatus_Failed;

#ifdef MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    
        ExitMonitor(&uStatus);
#endif // MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    

        return fStatus;
    }

    if (!pluginHost) {
        fStatus = nsJVMStatus_Failed;

#ifdef MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    
        ExitMonitor(&uStatus);
#endif // MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    

        return fStatus;
    }

    nsIPlugin* pluginFactory = NULL;
     // this code is the correct way to obtain pluggable JVM
    nsCOMPtr<nsIPlugin> f = 
             do_GetService(NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE, &err);
    if (NS_FAILED(err) || !f) {
        err = pluginHost->GetPluginFactory(NS_JVM_MIME_TYPE, &pluginFactory);
    } 
    else {
        pluginFactory  = f;
    }
    
    if (pluginFactory == NULL) {
        fStatus = nsJVMStatus_Failed;

#ifdef MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    
        ExitMonitor(&uStatus);
#endif // MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    

        return fStatus;
    }

    nsresult rslt = pluginFactory->QueryInterface(kIJVMPluginIID, (void**)&fJVM);
    if (rslt != NS_OK) {
        PR_ASSERT(fJVM == NULL);
        fStatus = nsJVMStatus_Failed;

#ifdef MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    
        ExitMonitor(&uStatus);
#endif // MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    

        return fStatus;
    }

    // beard: do we really need an explicit startup mechanim for the JVM?
    // since we obtained a working JVM plugin, assume it is running.
    fStatus = nsJVMStatus_Running;

#if 0
    JSContext* crippledContext = LM_GetCrippledContext();
    MaybeStartupLiveConnect(crippledContext, JS_GetGlobalObject(crippledContext));
#endif

    fJVM->Release();

#ifdef DEBUG
    PRIntervalTime end = PR_IntervalNow();
    PRInt32 d = PR_IntervalToMilliseconds(end - start);
    PR_LOG(NSJAVA, PR_LOG_ALWAYS,
           ("Starting java...%s (%ld ms)",
            (fStatus == nsJVMStatus_Running ? "done" : "failed"), d));
#endif

#ifdef MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    
        ExitMonitor(&uStatus);
#endif // MOZ_OJI_REQUIRE_THREAD_SAFE_ON_STARTUP    

 /* TODO:

    if (someRandomContext) {
        FE_Progress(someRandomContext, XP_GetString(XP_PROGRESS_STARTING_JAVA_DONE));
    }
 */
    return fStatus;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsJVMManager::StartupLiveConnect ( JSRuntime runtime,
PRBool outStarted 
) [inline, virtual]

Attempts to start LiveConnect using the specified JSRuntime.

Implements nsILiveConnectManager.

Definition at line 143 of file nsJVMManager.h.

    {
       outStarted = MaybeStartupLiveConnect();
       return NS_OK;
    }

Here is the call graph for this function:

NS_METHOD nsJVMManager::Wait ( void address,
PRUint32  milli = 0 
) [virtual]

Waits on the monitor associated with the address (must be entered already).

If milli is 0, wait indefinitely.

Implements nsIThreadManager.

Definition at line 260 of file nsJVMManager.cpp.

{
       PRIntervalTime timeout = (milli > 0 ? PR_MillisecondsToInterval(milli) : PR_INTERVAL_NO_TIMEOUT);
       return (PR_CWait(address, timeout) == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE);
}
NS_METHOD nsJVMManager::WrapJavaObject ( JSContext context,
jobject  javaObject,
JSObject **  outJSObject 
) [virtual]

Creates a JavaScript wrapper for a Java object.

Implements nsILiveConnectManager.

Definition at line 455 of file nsJVMManager.cpp.

{
       if (NULL == outJSObject) {
              return NS_ERROR_NULL_POINTER; 
       }
       jsval val;
       if (JSJ_ConvertJavaObjectToJSValue(context, javaObject, &val)) {
              *outJSObject = JSVAL_TO_OBJECT(val);
              return NS_OK;
       }
       return NS_ERROR_FAILURE;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 230 of file nsJVMManager.h.

Definition at line 231 of file nsJVMManager.h.

nsISupports* nsJVMManager::fDebugManager [protected]

Definition at line 228 of file nsJVMManager.h.

Definition at line 229 of file nsJVMManager.h.

Definition at line 226 of file nsJVMManager.h.

Definition at line 232 of file nsJVMManager.h.

Definition at line 227 of file nsJVMManager.h.

The JavaEnabled variable to see if Java is Enabled or not.

Definition at line 122 of file nsIJVMManager.idl.


The documentation for this struct was generated from the following files: