Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This fix enables the Tasks->Java Console menu item to show the Java
Console provided by the JRE plugin if it is installed.

It also exposes nsIJVMManager as a full XPIDL citizen, with the progid
component://netscape/oji/jvm-mgr.  see modules/oji/public/nsIJVMManager.idl
for the methods that can be called.

Thanks to Trevor, John Bandauer, Brendan Eich and Robert Yang.
  • Loading branch information
edburns%acm.org committed Aug 12, 1999
1 parent 5c04b25 commit 76832ec
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 111 deletions.
10 changes: 6 additions & 4 deletions java/config/localdefs.mak
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# this file contains defs that should be in the top level mozilla/config
# directory, but may not be there due to tree update issues.

JAVA=$(JDKHOME)\bin\java
JAVAH=$(JDKHOME)\bin\JAVAH
JAVAH_FLAGS=-jni -classpath $(JAVAC_CLASSPATH)


!ifndef JAVA_HOME
JAVA_HOME=$(JDKHOME)
Expand All @@ -14,4 +10,10 @@ JAVA_DESTPATH = $(MOZ_SRC)\mozilla\dist\classes
DEFAULT_JAVA_SOURCEPATH = $(MOZ_SRC)\mozilla\sun-java\classsrc
JAVA_SOURCEPATH = $(MOZ_SRC)\mozilla\sun-java\classsrc11;$(DEFAULT_JAVA_SOURCEPATH)
JAVAC_ZIP=$(JAVA_HOME)\lib\classes.zip
JAVAC_CLASSPATH=$(JAVAC_ZIP)$(PATH_SEPARATOR)$(JAVA_DESTPATH)$(PATH_SEPARATOR)$(JAVA_SOURCEPATH)


JAVA=$(JDKHOME)\bin\java
JAVAH=$(JDKHOME)\bin\JAVAH
JAVAH_FLAGS=-jni -classpath $(JAVAC_CLASSPATH)

1 change: 1 addition & 0 deletions java/webclient/README
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ How To Build:

C:\WINNT\System32
%JDKHOME%\jre\bin
%JDKHOME%\bin

How to Run:

Expand Down
3 changes: 2 additions & 1 deletion modules/oji/public/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ VPATH = @srcdir@

include $(DEPTH)/config/autoconf.mk

XPIDLSRCS = nsIJVMManager.idl

MODULE = oji

EXPORTS = \
nsjvm.h \
nsIJRIPlugin.h \
nsIJVMConsole.h \
nsIJVMManager.h \
nsIJVMPlugin.h \
nsIJVMPluginInstance.h \
nsIJVMPluginTagInfo.h \
Expand Down
5 changes: 4 additions & 1 deletion modules/oji/public/makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ DEPTH = ..\..\..

MODULE = oji

XPIDLSRCS = \
.\nsIJVMManager.idl \
$(NULL)

EXPORTS = \
nsjvm.h \
nsIJRIPlugin.h \
nsIJVMConsole.h \
nsIJVMManager.h \
nsIJVMPlugin.h \
nsIJVMPluginInstance.h \
nsIJVMPluginTagInfo.h \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,9 @@
* Reserved.
*/

////////////////////////////////////////////////////////////////////////////////
// NETSCAPE JAVA VM PLUGIN EXTENSIONS
//
// This interface allows a Java virtual machine to be plugged into
// Communicator to implement the APPLET tag and host applets.
//
// Note that this is the C++ interface that the plugin sees. The browser
// uses a specific implementation of this, nsJVMPlugin, found in jvmmgr.h.
////////////////////////////////////////////////////////////////////////////////

#ifndef nsIJVMManager_h___
#define nsIJVMManager_h___

#include "nsISupports.h"
#include "nsISupports.idl"

%{C++
#ifndef JNI_H
#include "jni.h"
#endif
Expand All @@ -41,13 +29,13 @@
// to JVM plugins for browsers that support JVM plugins.


#define NS_IJVMMANAGER_IID \
{ /* a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe */ \
0xa1e5ed50, \
0xaa4a, \
0x11d1, \
{0x85, 0xb2, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
//#define NS_IJVMMANAGER_IID \
//{ /* a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe */ \
// 0xa1e5ed50, \
// 0xaa4a, \
// 0x11d1, \
// {0x85, 0xb2, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
//}

#define NS_JVMMANAGER_CID \
{ /* 38e7ef10-58df-11d2-8164-006008119d7a */ \
Expand All @@ -57,37 +45,43 @@
{0x81, 0x64, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
}

class nsIJVMPlugin;
class nsISecureEnv;
%}

interface nsIJVMPlugin;
interface nsISecureEnv;
native JNIEnv(JNIEnv *);

[scriptable, uuid(a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe)]
interface nsIJVMManager : nsISupports {

class nsIJVMManager : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IJVMMANAGER_IID)
%{C++
// NS_DEFINE_STATIC_IID_ACCESSOR(NS_IJVMMANAGER_IID)
NS_DEFINE_STATIC_CID_ACCESSOR(NS_JVMMANAGER_CID)
%}

/**
* 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_IMETHOD
CreateProxyJNI(nsISecureEnv* inSecureEnv, JNIEnv** outProxyEnv) = 0;

void CreateProxyJNI(in nsISecureEnv secureEnv, out JNIEnv outProxyEnv);

/**
* Returns the proxy JNI associated with the current thread, or NULL if no
* such association exists.
*/
NS_IMETHOD
GetProxyJNI(JNIEnv** outProxyEnv) = 0;
void GetProxyJNI(out JNIEnv outProxyEnv);

/**
* Returns whether or not Java is enabled.
*/
NS_IMETHOD
IsJavaEnabled(PRBool* outEnabled) = 0;
};
void IsJavaEnabled(out boolean outEnabled);

////////////////////////////////////////////////////////////////////////////////
/**
* Called from Java Console menu item.
*/

void ShowJavaConsole();

#endif /* nsIJVMManager_h___ */
};
10 changes: 3 additions & 7 deletions modules/oji/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ include $(topsrcdir)/config/config.mk

MODULE = ojiimpl

IS_COMPONENT = 1

ifdef MOZ_OJI
LIBRARY_NAME = oji

Expand All @@ -29,14 +31,8 @@ CPPSRCS = jvmmgr.cpp \


REQUIRES = img java js lay layer plugin plugimpl pref style util xpcom raptor oji caps

ifeq ($(NSPR_INCLUDE_DIR),)
INCLUDES += -I$(DIST)/include/private
else
INCLUDES += -I$(NSPR_INCLUDE_DIR)/private
endif

CFLAGS += -DJSJDLL=\"$(JSJDLL)\"
INCLUDES += -I$(NSPR_INCLUDE_DIR)/private
endif # MOZ_OJI

EXPORTS = jvmmgr.h \
Expand Down
1 change: 1 addition & 0 deletions modules/oji/src/makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ PUBLIC_HEADER_DIR=$(PUBLIC)\win16
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).$(DLL_SUFFIX) $(DIST)\bin\components

clobber::
$(RM_R) _jri
Expand Down
73 changes: 68 additions & 5 deletions modules/oji/src/nsCJVMManagerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,73 @@
#include "nsJVMManager.h"
#include "nsCJVMManagerFactory.h"
#include "nsIComponentManager.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"

static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kCJVMManagerCID, NS_JVMMANAGER_CID);
static NS_DEFINE_CID(kJVMManagerCID, NS_JVMMANAGER_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);

nsIServiceManager *theServiceManager = NULL;

///////////////////////////////////////////////////////////////////////////////
// Auto-registration functions START
///////////////////////////////////////////////////////////////////////////////

extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr,
const char *path)
{
nsresult rv;

nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) {
return rv;
}

nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) {
return rv;
}

rv = compMgr->RegisterComponent(kJVMManagerCID,
"JVM Manager Service",
"component://netscape/oji/jvm-mgr",
path,
PR_TRUE, PR_TRUE);

(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr,
const char *path)
{
nsresult rv;

nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) {
return rv;
}

nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) {
return rv;
}

rv = compMgr->UnregisterComponent(kJVMManagerCID, path);

(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

/*+++++++++++++++++++++++++++++++++++++++++++++++++
* NSGetFactory:
* Provides entry point to liveconnect dll.
Expand All @@ -45,10 +103,10 @@ NSGetFactory(nsISupports* serviceMgr,
const char *aProgID,
nsIFactory **aFactory)
{
if (!aClass.Equals(kCJVMManagerCID)) {
if (!aClass.Equals(kJVMManagerCID)) {
return NS_ERROR_FACTORY_NOT_LOADED; // XXX right error?
}

// first off, cache a reference to the service manager for later use.
if (theServiceManager == NULL) {
if (serviceMgr->QueryInterface(kIServiceManagerIID, (void**)&theServiceManager) != NS_OK)
Expand All @@ -57,9 +115,10 @@ NSGetFactory(nsISupports* serviceMgr,

// now, create the JVM manager factory.
nsCJVMManagerFactory* factory = new nsCJVMManagerFactory();
if (factory == NULL)
if (factory == NULL) {
return NS_ERROR_OUT_OF_MEMORY;

}

NS_ADDREF(factory);
*aFactory = factory;

Expand All @@ -72,6 +131,10 @@ NSCanUnload(nsISupports* serviceMgr)
return PR_FALSE;
}

///////////////////////////////////////////////////////////////////////////////
// Auto-registration functions END
///////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
// from nsISupports
Expand Down
Loading

0 comments on commit 76832ec

Please sign in to comment.