From 43d5a99638e2e906564d1e7ac878fbf0beb2af33 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Sat, 29 Mar 2008 15:35:06 +0000 Subject: [PATCH] [220126] [dstore][api][breaking] executeThread() api for ISystemService --- .../dstore/core/server/ISystemService.java | 9 ++++++ .../dstore/core/server/SecuredThread.java | 28 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java index fea7399712a..a25b6dcc77e 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java @@ -26,4 +26,13 @@ public interface ISystemService * @param client the object of the client */ public void setThreadSecurity(Client client); + + /** + * This method is used to execute run() in a thread assigned + * from thread pools. + * + * @param securedThread the securedThread object that implements + * Runnable. + */ + public void executeThread(SecuredThread securedThread); } diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java index 46e7ca78ae9..db5aa6989c0 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java @@ -132,6 +132,32 @@ public class SecuredThread extends Thread super.run(); } - + + /** + * When start() is called, a check is made to see if there is an ISystemService. + * If there is, the ISystemService.executeThread(SecuredThread) is called. + * In this case, the run() method is invoked in a thread assigned from the running + * work threads + * If there isn't, the super.start() is called. + * In this case. the run() method is invoked as a new thread. + */ + public void start() + { + try + { + ISystemService systemService = SystemServiceManager.getInstance().getSystemService(); + if (systemService != null){ + systemService.executeThread(this); + } + else + { + super.start(); + } + } + catch(Throwable e) + { + e.printStackTrace(new PrintWriter(System.err)); + } + } }