* NOT PART OF TBOX BUILDS *
Fixed bug with [out] parametrs in java. Improved component registration. Added test for accessing ComponentManager from java git-svn-id: svn://10.0.0.236/trunk@79594 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -41,7 +41,7 @@ bcJavaSample.jar.comp: manifest bcIJavaSample.class bcJavaSample.class
|
||||
$(JDKHOME)/bin/jar cvfm bcJavaSample.jar.comp manifest *.class
|
||||
.java.class:
|
||||
$(JDKHOME)/bin/javac -classpath .:../classes $<
|
||||
install-component: bcJavaSample.jar.comp bcJavaSample.jar.info
|
||||
install-component: bcJavaSample.jar.comp bcJavaSample.jar.info
|
||||
cp bcJavaSample.jar.comp bcJavaSample.jar.info $(DEPTH)/dist/bin/components/
|
||||
|
||||
clobber-java:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIComponentManager.idl"
|
||||
|
||||
[scriptable, uuid(ca1e2656-1dd1-11b2-9c4e-f49ea557abde)]
|
||||
interface bcIJavaSample : nsISupports
|
||||
@@ -8,5 +9,5 @@ interface bcIJavaSample : nsISupports
|
||||
void test2(in bcIJavaSample o);
|
||||
void test3(in PRUint32 count,[array, size_is(count)] in long valueArray);
|
||||
void test4(in PRUint32 count,[array, size_is(count)] inout string valueArray);
|
||||
|
||||
void test5(in nsIComponentManager cm);
|
||||
};
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
/*
|
||||
* ************* DO NOT EDIT THIS FILE ***********
|
||||
*
|
||||
* This file was automatically generated from bcIJavaSample.idl.
|
||||
*/
|
||||
|
||||
import org.mozilla.xpcom.*;
|
||||
|
||||
/**
|
||||
* Interface nsISample
|
||||
* Interface bcIJavaSample
|
||||
*
|
||||
* IID: 0xca1e2656-1dd1-11b2-9c4e-f49ea557abde
|
||||
*/
|
||||
|
||||
import org.mozilla.xpcom.*;
|
||||
|
||||
public interface bcIJavaSample extends nsISupports
|
||||
{
|
||||
public static final String IID =
|
||||
"ca1e2656-1dd1-11b2-9c4e-f49ea557abde";
|
||||
void queryInterface(IID iid, Object[] result);
|
||||
void test0();
|
||||
void test1(int l);
|
||||
void test2(bcIJavaSample o);
|
||||
void test3(int count, int[] valueArray);
|
||||
void test4(int count, String[][] valueArray);
|
||||
|
||||
|
||||
/* void test0 (); */
|
||||
public void test0();
|
||||
|
||||
/* void test1 (in long l); */
|
||||
public void test1(int l);
|
||||
|
||||
/* void test2 (in bcIJavaSample o); */
|
||||
public void test2(bcIJavaSample o);
|
||||
|
||||
/* void test3 (in PRUint32 count, [array, size_is (count)] in long valueArray); */
|
||||
public void test3(int count, int[] valueArray);
|
||||
|
||||
/* void test4 (in PRUint32 count, [array, size_is (count)] inout string valueArray); */
|
||||
public void test4(int count, String[][] valueArray);
|
||||
|
||||
/* void test5 (in nsIComponentManager cm); */
|
||||
public void test5(nsIComponentManager cm);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* end
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
#define BC_JAVA_SAMPLE_CID \
|
||||
@@ -93,6 +94,12 @@ NS_IMETHODIMP bcJavaSample::Test4(PRUint32 count, char ***valueArray) {
|
||||
*valueArray = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void test5 (in nsIComponentManager cm); */
|
||||
NS_IMETHODIMP bcJavaSample::Test5(nsIComponentManager *cm) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void test() {
|
||||
printf("--BlackConnect test start\n");
|
||||
nsresult r;
|
||||
@@ -130,6 +137,20 @@ void test() {
|
||||
printf("valueArray2[%d]=%s\n",i,(*valueArray2)[i]);
|
||||
}
|
||||
}
|
||||
{
|
||||
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
printf("--[c++] bcJavaSample before test->Test5(cm)\n");
|
||||
test->Test5(cm);
|
||||
|
||||
nsIEnumerator *enumerator;
|
||||
rv = cm->EnumerateCLSIDs(&enumerator);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("--[c++] can get enumerator\n");
|
||||
}
|
||||
printf("--[c++] bcJavaSample after test->Test5(cm)\n");
|
||||
}
|
||||
printf("--BlackConnect test end\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,61 @@ public class bcJavaSample implements bcIJavaSample {
|
||||
String[] returnArray = {"4","3","2","1"};
|
||||
valueArray[0] = returnArray;
|
||||
}
|
||||
/* void test5 (in nsIComponentManager cm); */
|
||||
public void test5(nsIComponentManager cm) {
|
||||
System.out.println("--[java]bcJavaSample.test5");
|
||||
try {
|
||||
nsIEnumerator [] retval = new nsIEnumerator[1];
|
||||
cm.enumerateContractIDs(retval);
|
||||
nsIEnumerator enumerator = retval[0];
|
||||
System.out.println("--[java] before calling enumerator.firts() "+
|
||||
"enumerator==null "+(enumerator==null));
|
||||
|
||||
enumerator.first();
|
||||
int counter = 0;
|
||||
nsISupports obj[] = new nsISupports[1];
|
||||
String str[] = new String[1];
|
||||
nsISupportsString strObj[] = new nsISupportsString[1];
|
||||
while (true) {
|
||||
enumerator.currentItem(obj);
|
||||
if (obj[0] == null ||
|
||||
counter > 10) {
|
||||
break;
|
||||
}
|
||||
obj[0].queryInterface(nsISupportsStringIID,strObj);
|
||||
strObj[0].toString(str);
|
||||
System.out.println("--[java] bcJavaSample.Test5 string "+str[0]);
|
||||
enumerator.next(); counter++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
static IID bcIJavaSampleIID = new IID(bcIJavaSample.IID);
|
||||
static IID nsISupportsIID = new IID(nsISupports.IID);
|
||||
static IID nsIComponenstManagerIID = new IID(nsIComponentManager.IID);
|
||||
static IID nsISupportsStringIID = new IID(nsISupportsString.IID);
|
||||
static {
|
||||
try {
|
||||
Class nsIComponentManagerClass =
|
||||
Class.forName("org.mozilla.xpcom.nsIComponentManager");
|
||||
Class nsIEnumeratorClass =
|
||||
Class.forName("org.mozilla.xpcom.nsIEnumerator");
|
||||
Class nsISupportsStringClass =
|
||||
Class.forName("org.mozilla.xpcom.nsISupportsString");
|
||||
InterfaceRegistry.register(nsIComponentManagerClass);
|
||||
InterfaceRegistry.register(nsIEnumeratorClass);
|
||||
InterfaceRegistry.register(nsISupportsStringClass);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user