*not part of the buld*
blackConnect tests update git-svn-id: svn://10.0.0.236/trunk@99925 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -29,48 +29,102 @@ import java.io.FileOutputStream;
|
||||
|
||||
public class MThreadComponent1 implements iMThreadComponent1, iMThreadComponent {
|
||||
private iMThreadContext context = null;
|
||||
private nsIComponentManager com=null;
|
||||
private int thr=0;
|
||||
private int stg=0;
|
||||
|
||||
public MThreadComponent1() {
|
||||
System.out.println("DEbug:avm:MThreadComponent1 constructor");
|
||||
}
|
||||
|
||||
|
||||
public void initialize(iMThreadContext context) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1:initialize Thread is " + Thread.currentThread().getName());
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void tHack(nsIComponentManager cm) {
|
||||
nsIFactory factory = null;
|
||||
System.out.println("DEbug:avm:tHack");
|
||||
if(cm == null) {
|
||||
System.err.println("DEbug:avm:tHack:ComponentManager is NULL!!!!!");
|
||||
return;
|
||||
}
|
||||
com=cm;
|
||||
factory = cm.findFactory(iMThreadContextCID);
|
||||
|
||||
if(factory == null) {
|
||||
System.err.println("DEbug:avm:tHack:Factory is NULL!!!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
Object res = factory.createInstance(null, iMThreadContext.IID);
|
||||
if(res == null) {
|
||||
System.err.println("DEbug:avm:tHack:Instance is NULL!!!!!");
|
||||
return;
|
||||
}
|
||||
context = (iMThreadContext)res;
|
||||
if(context == null) {
|
||||
System.err.println("Create instance failed!! Server is NULLLLLLLLLLLLLLLLLLL");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public iMThreadComponent loadComponent(CID classID) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1:loadComponent");
|
||||
nsIComponentManager cm = context.getComponentManager();
|
||||
|
||||
nsIFactory factory = cm.findFactory(classID);
|
||||
if(factory == null) {
|
||||
System.out.println("DEbug:avm:Factory is NULL!!!!!");
|
||||
System.err.println("DEbug:avm:loadComponent:Factory is NULL!!!!!");
|
||||
return null;
|
||||
}
|
||||
|
||||
iMThreadComponent component = (iMThreadComponent)factory.createInstance(null, iMThreadComponent.IID);
|
||||
return component;
|
||||
}
|
||||
|
||||
/* void Execute (); */
|
||||
public void execute(String tName) {
|
||||
|
||||
public void execute(int thread, int stage) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1:execute.");
|
||||
String cThreadName = Thread.currentThread().getName();
|
||||
if(tName.equals(cThreadName)) {
|
||||
System.out.println("PASSED: original and expected names equals to " + tName);
|
||||
} else {
|
||||
System.out.println("FAILED: Current thread name is " + cThreadName + " instead of " + tName );
|
||||
}
|
||||
CID classID = new CID(context.getNext());
|
||||
iMThreadComponent component = loadComponent(classID);
|
||||
if(component == null) {
|
||||
System.out.println("Can't load component");
|
||||
return;
|
||||
}
|
||||
System.out.println("Initialize of " + component + " called in thread " + cThreadName);
|
||||
component.initialize(context);
|
||||
(new ExecutionThread(component)).run();
|
||||
//component.execute();
|
||||
|
||||
try{
|
||||
DataOutputStream f=new DataOutputStream(new FileOutputStream(context.getResFile(),true));
|
||||
f.writeBytes((new Integer(thread)).toString()+","+(new Integer(stage)).toString()+","+cThreadName+"\n");
|
||||
f.close();
|
||||
} catch(Exception e) {
|
||||
System.err.println("Exception during writing the file: " +e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CID classID = new CID(context.getContractID(thread+1,stage+1));
|
||||
|
||||
if (!(classID.toString().equals("org.mozilla.xpcom.CID@null"))){
|
||||
iMThreadComponent component = loadComponent(classID);
|
||||
if(component == null) {
|
||||
System.err.println("Can't load component");
|
||||
} else {
|
||||
component.initialize(context);
|
||||
component.tHack(com);
|
||||
(new ExecutionThread(component)).run(thread+1,stage+1);
|
||||
}
|
||||
}
|
||||
|
||||
classID = new CID(context.getContractID(thread,stage+1));
|
||||
|
||||
if (!(classID.toString().equals("org.mozilla.xpcom.CID@null"))){
|
||||
iMThreadComponent component = loadComponent(classID);
|
||||
if(component == null) {
|
||||
System.err.println("Can't load component");
|
||||
} else {
|
||||
component.initialize(context);
|
||||
component.tHack(com);
|
||||
component.execute(thread,stage+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Object queryInterface(IID iid) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1::queryInterface iid="+iid);
|
||||
if ( iid.equals(nsISupports.IID)
|
||||
@@ -81,13 +135,12 @@ public class MThreadComponent1 implements iMThreadComponent1, iMThreadComponent
|
||||
}
|
||||
}
|
||||
|
||||
static CID J2XINServerCID = new CID("1ddc5b10-9852-11d4-aa22-00a024a8bbac");
|
||||
static CID iMThreadContextCID = new CID("139b8350-280a-46d0-8afc-f1939173c2ea");
|
||||
static {
|
||||
try {
|
||||
Class nsIComponentManagerClass =
|
||||
Class.forName("org.mozilla.xpcom.nsIComponentManager");
|
||||
InterfaceRegistry.register(nsIComponentManagerClass);
|
||||
|
||||
Class iMThreadComponentClass =
|
||||
Class.forName("org.mozilla.xpcom.iMThreadComponent");
|
||||
InterfaceRegistry.register(iMThreadComponentClass);
|
||||
@@ -104,11 +157,3 @@ public class MThreadComponent1 implements iMThreadComponent1, iMThreadComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user