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.


git-svn-id: svn://10.0.0.236/trunk@43214 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
1999-08-12 01:56:18 +00:00
parent 1cf8df04f0
commit e65bc07e20
14 changed files with 156 additions and 112 deletions

View File

@@ -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)
@@ -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)

View File

@@ -34,6 +34,7 @@ How To Build:
C:\WINNT\System32
%JDKHOME%\jre\bin
%JDKHOME%\bin
How to Run:

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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
@@ -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 */ \
@@ -57,13 +45,19 @@
{0x81, 0x64, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
}
class nsIJVMPlugin;
class nsISecureEnv;
%}
class nsIJVMManager : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IJVMMANAGER_IID)
interface nsIJVMPlugin;
interface nsISecureEnv;
native JNIEnv(JNIEnv *);
[scriptable, uuid(a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe)]
interface nsIJVMManager : nsISupports {
%{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).
@@ -71,23 +65,23 @@ public:
* 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___ */

View File

@@ -15,6 +15,8 @@ include $(topsrcdir)/config/config.mk
MODULE = ojiimpl
IS_COMPONENT = 1
ifdef MOZ_OJI
LIBRARY_NAME = oji
@@ -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 \

View File

@@ -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

View File

@@ -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.
@@ -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)
@@ -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;
@@ -72,6 +131,10 @@ NSCanUnload(nsISupports* serviceMgr)
return PR_FALSE;
}
///////////////////////////////////////////////////////////////////////////////
// Auto-registration functions END
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// from nsISupports

View File

@@ -83,6 +83,8 @@ static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID);
static NS_DEFINE_IID(kISymantecDebugManagerIID, NS_ISYMANTECDEBUGMANAGER_IID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_AGGREGATED(nsJVMManager);
@@ -139,6 +141,13 @@ nsJVMManager::IsJavaEnabled(PRBool* outEnabled)
return NS_OK;
}
NS_METHOD
nsJVMManager::ShowJavaConsole(void)
{
JVM_ShowConsole();
return NS_OK;
}
// nsIThreadManager:
NS_METHOD
@@ -300,15 +309,20 @@ nsJVMManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
return NS_OK;
}
if (aIID.Equals(kIThreadManagerIID)) {
*aInstancePtr = (void*) (nsIThreadManager*) this;
*aInstancePtr = (void*) NS_STATIC_CAST(nsIThreadManager*, this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kILiveConnectManagerIID)) {
*aInstancePtr = (void*) (nsILiveConnectManager*) this;
*aInstancePtr = (void*) NS_STATIC_CAST(nsILiveConnectManager*, this);
AddRef();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = GetInner();
NS_ADDREF((nsISupports*)*aInstancePtr);
return NS_OK;
}
#ifdef XP_PC
// Aggregates...
if (fDebugManager == NULL) {
@@ -779,47 +793,3 @@ nsJVMManager::AddToClassPath(const char* dirPath)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
class nsJVMFactory : public nsIFactory {
public:
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
nsJVMFactory(void);
virtual ~nsJVMFactory(void);
};
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
NS_IMPL_ISUPPORTS(nsJVMFactory, kIFactoryIID);
nsJVMFactory::nsJVMFactory(void)
{
}
nsJVMFactory::~nsJVMFactory(void)
{
}
NS_METHOD
nsJVMFactory::CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult)
{
return nsJVMManager::Create(aOuter, aIID, aResult);
}
NS_METHOD
nsJVMFactory::LockFactory(PRBool aLock)
{
// nothing to do here since we're not a DLL (yet)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -71,6 +71,10 @@ public:
*/
NS_IMETHOD
IsJavaEnabled(PRBool* outEnabled);
NS_METHOD
ShowJavaConsole(void);
/* from nsIThreadManager: */

View File

@@ -39,7 +39,6 @@
#ifdef OJI
#include "nsICapsManager.h"
#include "nsILiveconnect.h"
#include "nsIJVMManager.h"
#endif
#include "nsIPluginManager.h"
#include "nsIProperties.h"
@@ -201,7 +200,6 @@ static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
#ifdef OJI
static NS_DEFINE_CID(kCapsManagerCID, NS_CCAPSMANAGER_CID);
static NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
static NS_DEFINE_CID(kCJVMManagerCID, NS_JVMMANAGER_CID);
#endif
extern "C" void
@@ -284,6 +282,5 @@ NS_SetupRegistry()
#ifdef OJI
nsComponentManager::RegisterComponentLib(kCapsManagerCID, NULL, NULL, CAPS_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCLiveconnectCID, NULL, NULL, LIVECONNECT_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCJVMManagerCID, NULL, NULL, OJI_DLL, PR_FALSE, PR_FALSE);
#endif
}

View File

@@ -39,7 +39,6 @@
#ifdef OJI
#include "nsICapsManager.h"
#include "nsILiveconnect.h"
#include "nsIJVMManager.h"
#endif
#include "nsIPluginManager.h"
#include "nsIProperties.h"
@@ -206,7 +205,6 @@ static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
#ifdef OJI
static NS_DEFINE_CID(kCapsManagerCID, NS_CCAPSMANAGER_CID);
static NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
static NS_DEFINE_CID(kCJVMManagerCID, NS_JVMMANAGER_CID);
#endif
extern "C" void
@@ -407,7 +405,6 @@ NS_SetupRegistry()
#ifdef OJI
nsComponentManager::RegisterComponentLib(kCapsManagerCID, NULL, NULL, CAPS_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCLiveconnectCID, NULL, NULL, LIVECONNECT_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCJVMManagerCID, NULL, NULL, OJI_DLL, PR_FALSE, PR_FALSE);
#endif
}

View File

@@ -29,6 +29,21 @@ function toHistory()
}
}
function toJavaConsole()
{
try{
var cid =
Components.classes['component://netscape/oji/jvm-mgr'];
var iid = Components.interfaces.nsIJVMManager;
var jvmMgr = cid.getService(iid);
jvmMgr.ShowJavaConsole();
} catch(e) {
}
}
function toOpenWindowByType( inType, uri )
{
var windowManager = Components.classes['component://netscape/rdf/datasource?name=window-mediator'].getService();
@@ -40,7 +55,7 @@ function toOpenWindowByType( inType, uri )
if ( topWindow )
topWindow.focus();
else
window.open(uri, "", "chrome,menubar,toolbar,resizable");
window.open(uri, "", "chrome,menubar");
}
function CycleWindow( inType, inChromeURL )
@@ -60,7 +75,7 @@ function CycleWindow( inType, inChromeURL )
if ( topWindowOfType == null )
{
dump( " no windows of this type so create a new one \n");
window.open( inChromeURL, "","chrome,menubar,toolbar,resizable" );
window.open( inChromeURL, "","chrome,menubar,toolbar" );
return;
}
@@ -103,7 +118,7 @@ function CycleWindow( inType, inChromeURL )
else
{
dump("open window \n");
window.open( inChromeURL, "","chrome,menubar,toolbar,resizable" );
window.open( inChromeURL, "","chrome,menubar" );
}
}

View File

@@ -13,7 +13,7 @@
<!ENTITY securityInfoCmd.label ".Security Info">
<!ENTITY messageCenterCmd.label ".Message Center">
<!ENTITY importUtilCmd.label ".Import Utility">
<!ENTITY javaConsoleCmd.label ".Java Console">
<!ENTITY javaConsoleCmd.label "Java Console">
<!-- taskbar -->
<!ENTITY mozillaButton.label "Mozilla">
@@ -26,5 +26,5 @@
<!ENTITY bonsai.label "Look at Bonsai">
<!ENTITY booksButton.label "Buy Books at Fatbrain">
<!ENTITY cdButton.label "Buy CDs at CDNOW">
<!ENTITY cdButton.label "Buy CD's at CDNOW">
<!ENTITY lifeButton.label "Get a Life at Match.com">