#82443# added thread run hooks

This commit is contained in:
Kay Ramme 2000-12-22 09:01:29 +00:00
parent 843b962cf2
commit bd051fffa5
2 changed files with 56 additions and 103 deletions

View file

@ -2,9 +2,9 @@
* *
* $RCSfile: java_remote_bridge.java,v $ * $RCSfile: java_remote_bridge.java,v $
* *
* $Revision: 1.8 $ * $Revision: 1.9 $
* *
* last change: $Author: cdt $ $Date: 2000-11-30 18:59:51 $ * last change: $Author: kr $ $Date: 2000-12-22 10:01:29 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@ -78,8 +78,11 @@ import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import com.sun.star.lib.sandbox.IInvokeHook;
import com.sun.star.lib.sandbox.generic.DispatcherAdapterBase; import com.sun.star.lib.sandbox.generic.DispatcherAdapterBase;
import com.sun.star.bridge.XBridge; import com.sun.star.bridge.XBridge;
import com.sun.star.bridge.XInstanceProvider; import com.sun.star.bridge.XInstanceProvider;
@ -125,7 +128,7 @@ import com.sun.star.uno.IQueryInterface;
* The protocol to used is passed by name, the bridge * The protocol to used is passed by name, the bridge
* then looks for it under <code>com.sun.star.lib.uno.protocols</code>. * then looks for it under <code>com.sun.star.lib.uno.protocols</code>.
* <p> * <p>
* @version $Revision: 1.8 $ $ $Date: 2000-11-30 18:59:51 $ * @version $Revision: 1.9 $ $ $Date: 2000-12-22 10:01:29 $
* @author Kay Ramme * @author Kay Ramme
* @see com.sun.star.lib.uno.environments.remote.IProtocol * @see com.sun.star.lib.uno.environments.remote.IProtocol
* @since UDK1.0 * @since UDK1.0
@ -137,6 +140,12 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
static private final boolean DEBUG = false; static private final boolean DEBUG = false;
/**
* E.g. to get privleges for security managers, it is
* possible to set a hook for the <code>MessageDispatcher</code> thread.
*/
static public IInvokeHook __MessageDispatcher_run_hook;
/** /**
* The name of the service. * The name of the service.
* <p> * <p>
@ -187,64 +196,29 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
private class MessageDispatcher extends Thread { public class MessageDispatcher extends Thread {
boolean _quit = false; boolean _quit = false;
MessageDispatcher() { MessageDispatcher() {
super("MessageDispatcher"); super("MessageDispatcher");
} }
public void run() { public void run() {
if(__MessageDispatcher_run_hook != null) {
//--!! hack try {
__MessageDispatcher_run_hook.invoke(this, "doWork", null);
java.lang.reflect.Method enab = null; }
catch(Exception exception) { // should not fly
System.err.println(getClass().getName() + " - unexpected: method >doWork< threw an exception - " + exception);
try { exception.printStackTrace();
Class c = Class.forName("netscape.security.PrivilegeManager"); }
if (c != null) {
enab = c.getMethod("enablePrivilege", new Class[] { String.class });
enab.invoke(null, new Object[] { "Netcaster"});
enab.invoke(null, new Object[] { "IIOPRuntime"});
enab.invoke(null, new Object[] { "UniversalSystemClipboardAccess"});
enab.invoke(null, new Object[] { "UniversalSetFactory"});
enab.invoke(null, new Object[] { "UniversalPrintJobAccess"});
enab.invoke(null, new Object[] { "UniversalTopLevelWindow"});
enab.invoke(null, new Object[] { "UniversalClassLoaderAccess"});
enab.invoke(null, new Object[] { "MarimbaInternalTarget"});
enab.invoke(null, new Object[] { "UniversalThreadGroupAccess"});
enab.invoke(null, new Object[] { "UniversalExecAccess"});
enab.invoke(null, new Object[] { "UniversalExitAccess"});
enab.invoke(null, new Object[] { "UniversalLinkAccess"});
enab.invoke(null, new Object[] { "UniversalPropertyWrite"});
enab.invoke(null, new Object[] { "UniversalPropertyRead"});
enab.invoke(null, new Object[] { "UniversalFileRead"});
enab.invoke(null, new Object[] { "UniversalFileWrite"});
enab.invoke(null, new Object[] { "UniversalFileDelete"});
enab.invoke(null, new Object[] { "UniversalFdRead"}); }
enab.invoke(null, new Object[] { "UniversalFdWrite"});
enab.invoke(null, new Object[] { "UniversalListen"});
enab.invoke(null, new Object[] { "UniversalAccept"});
enab.invoke(null, new Object[] { "UniversalConnect"});
enab.invoke(null, new Object[] { "UniversalMulticast"});
enab.invoke(null, new Object[] { "UniversalPackageAccess"});
enab.invoke(null, new Object[] { "UniversalAwtEventQueueAccess"});
enab.invoke(null, new Object[] { "UniversalBrowserRead"});
enab.invoke(null, new Object[] { "UniversalBrowserWrite"});
enab.invoke(null, new Object[] { "UniversalSendMail"});
enab.invoke(null, new Object[] { "UniversalThreadAccess"});
enab.invoke(null, new Object[] { "Debugger"});
enab.invoke(null, new Object[] { "PresentationAccess"});
enab.invoke(null, new Object[] { "PrivateRegistryAccess"});
enab.invoke(null, new Object[] { "SignonAccess"});
enab.invoke(null, new Object[] { "SpreadsheetAccess"});
enab.invoke(null, new Object[] { "WordProcessorAccess"});
} }
catch (Throwable cnfe) { else
doWork();
} }
public void doWork() {
try { try {
do { do {
try { try {

View file

@ -2,9 +2,9 @@
* *
* $RCSfile: JobQueue.java,v $ * $RCSfile: JobQueue.java,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: cdt $ $Date: 2000-11-30 18:56:25 $ * last change: $Author: kr $ $Date: 2000-12-22 10:01:27 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@ -64,9 +64,14 @@ package com.sun.star.lib.uno.environments.remote;
import java.util.Hashtable; import java.util.Hashtable;
import com.sun.star.lib.sandbox.IInvokeHook;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
/** /**
* The <code>JobQueue</code> implements a queue for jobs. * The <code>JobQueue</code> implements a queue for jobs.
* For every jobs thread id exists a job queue which is registered * For every jobs thread id exists a job queue which is registered
@ -76,7 +81,7 @@ import com.sun.star.uno.UnoRuntime;
* (put by <code>putjob</code>) into the async queue, which is only * (put by <code>putjob</code>) into the async queue, which is only
* known by the sync queue. * known by the sync queue.
* <p> * <p>
* @version $Revision: 1.5 $ $ $Date: 2000-11-30 18:56:25 $ * @version $Revision: 1.6 $ $ $Date: 2000-12-22 10:01:27 $
* @author Kay Ramme * @author Kay Ramme
* @see com.sun.star.lib.uno.environments.remote.ThreadPool * @see com.sun.star.lib.uno.environments.remote.ThreadPool
* @see com.sun.star.lib.uno.environments.remote.Job * @see com.sun.star.lib.uno.environments.remote.Job
@ -89,6 +94,13 @@ public class JobQueue {
*/ */
public static final boolean DEBUG = false; public static final boolean DEBUG = false;
/**
* E.g. to get privleges for security managers, it is
* possible to set a hook for the <code>JobDispatcher</code> thread.
*/
static public IInvokeHook __JobDispatcher_run_hook;
static protected int __instances; static protected int __instances;
protected Job _head; // the head of the job list protected Job _head; // the head of the job list
@ -137,55 +149,7 @@ public class JobQueue {
return _threadId; return _threadId;
} }
public void run() { public void doWork() {
if(DEBUG) System.err.println("ThreadPool$JobDispatcher.run");
//--!! hack
java.lang.reflect.Method enab = null;
try {
Class c = Class.forName("netscape.security.PrivilegeManager");
if (c != null) {
enab = c.getMethod("enablePrivilege", new Class[] { String.class });
enab.invoke(null, new Object[] { "Netcaster"});
enab.invoke(null, new Object[] { "IIOPRuntime"});
enab.invoke(null, new Object[] { "UniversalSystemClipboardAccess"});
enab.invoke(null, new Object[] { "UniversalSetFactory"});
enab.invoke(null, new Object[] { "UniversalPrintJobAccess"});
enab.invoke(null, new Object[] { "UniversalTopLevelWindow"});
enab.invoke(null, new Object[] { "UniversalClassLoaderAccess"});
enab.invoke(null, new Object[] { "MarimbaInternalTarget"});
enab.invoke(null, new Object[] { "UniversalThreadGroupAccess"});
enab.invoke(null, new Object[] { "UniversalExecAccess"});
enab.invoke(null, new Object[] { "UniversalExitAccess"});
enab.invoke(null, new Object[] { "UniversalLinkAccess"});
enab.invoke(null, new Object[] { "UniversalPropertyWrite"});
enab.invoke(null, new Object[] { "UniversalPropertyRead"});
enab.invoke(null, new Object[] { "UniversalFileRead"});
enab.invoke(null, new Object[] { "UniversalFileWrite"});
enab.invoke(null, new Object[] { "UniversalFileDelete"});
enab.invoke(null, new Object[] { "UniversalFdRead"}); }
enab.invoke(null, new Object[] { "UniversalFdWrite"});
enab.invoke(null, new Object[] { "UniversalListen"});
enab.invoke(null, new Object[] { "UniversalAccept"});
enab.invoke(null, new Object[] { "UniversalConnect"});
enab.invoke(null, new Object[] { "UniversalMulticast"});
enab.invoke(null, new Object[] { "UniversalPackageAccess"});
enab.invoke(null, new Object[] { "UniversalAwtEventQueueAccess"});
enab.invoke(null, new Object[] { "UniversalBrowserRead"});
enab.invoke(null, new Object[] { "UniversalBrowserWrite"});
enab.invoke(null, new Object[] { "UniversalSendMail"});
enab.invoke(null, new Object[] { "UniversalThreadAccess"});
enab.invoke(null, new Object[] { "Debugger"});
enab.invoke(null, new Object[] { "PresentationAccess"});
enab.invoke(null, new Object[] { "PrivateRegistryAccess"});
enab.invoke(null, new Object[] { "SignonAccess"});
enab.invoke(null, new Object[] { "SpreadsheetAccess"});
enab.invoke(null, new Object[] { "WordProcessorAccess"});
}
catch (Throwable cnfe) {
}
try { try {
enter(1000, null); enter(1000, null);
} }
@ -193,6 +157,21 @@ public class JobQueue {
System.err.println(getClass().getName() + " - exception occurred:" + exception); System.err.println(getClass().getName() + " - exception occurred:" + exception);
if(DEBUG) ;exception.printStackTrace(); if(DEBUG) ;exception.printStackTrace();
} }
}
public void run() {
if(DEBUG) System.err.println("ThreadPool$JobDispatcher.run");
if(__JobDispatcher_run_hook != null) {
try {
__JobDispatcher_run_hook.invoke(this, "doWork", null);
}
catch(Exception exception) { // should not fly
System.err.println(getClass().getName() + " - unexpected: method >doWork< threw an exception - " + exception);
}
}
else
doWork();
// dispose the jobQueue // dispose the jobQueue
// dispose(); // dispose();