diff options
author | Kay Ramme <kr@openoffice.org> | 2000-12-22 09:01:29 +0000 |
---|---|---|
committer | Kay Ramme <kr@openoffice.org> | 2000-12-22 09:01:29 +0000 |
commit | bd051fffa5d5d0c3442b368e230080349015f87d (patch) | |
tree | 71ccf3dc4e35de6fc14779966892867a75f64ff2 /jurt | |
parent | 843b962cf26de7fcd4db9321db0c1dd241e69990 (diff) |
#82443# added thread run hooks
Diffstat (limited to 'jurt')
-rw-r--r-- | jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java | 76 | ||||
-rw-r--r-- | jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java | 83 |
2 files changed, 56 insertions, 103 deletions
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java index 6721f895d8f4..2e34af011314 100644 --- a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java +++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java @@ -2,9 +2,9 @@ * * $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 * either of the following licenses @@ -78,8 +78,11 @@ import java.util.Hashtable; import java.util.Vector; +import com.sun.star.lib.sandbox.IInvokeHook; + import com.sun.star.lib.sandbox.generic.DispatcherAdapterBase; + import com.sun.star.bridge.XBridge; 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 * then looks for it under <code>com.sun.star.lib.uno.protocols</code>. * <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 * @see com.sun.star.lib.uno.environments.remote.IProtocol * @since UDK1.0 @@ -138,6 +141,12 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid /** + * 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. * <p> * @deprecated as of UDK 1.0 @@ -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; MessageDispatcher() { super("MessageDispatcher"); } - public void 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"}); + public void run() { + if(__MessageDispatcher_run_hook != null) { + try { + __MessageDispatcher_run_hook.invoke(this, "doWork", null); + } + catch(Exception exception) { // should not fly + System.err.println(getClass().getName() + " - unexpected: method >doWork< threw an exception - " + exception); + exception.printStackTrace(); + } } - catch (Throwable cnfe) { + else + doWork(); } - + public void doWork() { try { do { try { diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java b/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java index e0382d251828..78a419d3041e 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java @@ -2,9 +2,9 @@ * * $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 * either of the following licenses @@ -64,9 +64,14 @@ package com.sun.star.lib.uno.environments.remote; import java.util.Hashtable; + +import com.sun.star.lib.sandbox.IInvokeHook; + + import com.sun.star.uno.UnoRuntime; + /** * The <code>JobQueue</code> implements a queue for jobs. * 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 * known by the sync queue. * <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 * @see com.sun.star.lib.uno.environments.remote.ThreadPool * @see com.sun.star.lib.uno.environments.remote.Job @@ -89,6 +94,13 @@ public class JobQueue { */ 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; protected Job _head; // the head of the job list @@ -137,55 +149,7 @@ public class JobQueue { return _threadId; } - public void run() { - 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) { - } - + public void doWork() { try { enter(1000, null); } @@ -193,6 +157,21 @@ public class JobQueue { System.err.println(getClass().getName() + " - exception occurred:" + exception); 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(); |