diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleLoaderGetter.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleLoaderGetter.java deleted file mode 100644 index 74d9c3df01..0000000000 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleLoaderGetter.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.core.reflect; - -import org.eclipse.osgi.framework.internal.core.AbstractBundle; -import org.eclipse.osgi.framework.internal.core.BundleHost; -import org.eclipse.osgi.internal.loader.BundleLoader; -import org.eclipse.osgi.internal.loader.BundleLoaderProxy; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleReference; - -/** - * Utility class to get the BundleLoader object associated with a Bundle, to - * potentially synchronize against that object. - * - *
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 13, 2014 3500 bclement Initial creation - * - *- * - * @author bclement - * @version 1.0 - * @see BundleSynchronizer - */ -public class BundleLoaderGetter { - - private BundleLoaderGetter() { - } - - /** - * Attempts to retrieve the BundleLoader associated with the bundle. Returns - * the BundleLoader or null if it could not be retrieved. - * - * @param bundle - * the bundle to retrieve the associated BundleLoader for - * @return the BundleLoader or null - */ - @SuppressWarnings("restriction") - protected static BundleLoader getBundleLoader(Bundle bundle) { - BundleLoader rval = null; - if (bundle instanceof AbstractBundle) { - BundleDescription bundleDesc = ((AbstractBundle) bundle) - .getBundleDescription(); - if (bundleDesc != null) { - Object o = bundleDesc.getUserObject(); - if (!(o instanceof BundleLoaderProxy)) { - if (o instanceof BundleReference) - o = ((BundleReference) o).getBundle(); - if (o instanceof BundleHost) - o = ((BundleHost) o).getLoaderProxy(); - } - if (o instanceof BundleLoaderProxy) { - rval = ((BundleLoaderProxy) o).getBundleLoader(); - } - } - } - return rval; - } - -} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleSynchronizer.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleSynchronizer.java deleted file mode 100644 index 9f1db071c0..0000000000 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleSynchronizer.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.core.reflect; - -import org.eclipse.osgi.framework.internal.core.BundleRepository; -import org.eclipse.osgi.internal.loader.BundleLoader; -import org.osgi.framework.Bundle; - -/** - * If a call to BundleWiring.getClassLoader() is invoked on a thread other than - * main/UI thread, then there is a possible deadlock if the application shuts - * down while the BundleWiring.getClassLoader() call is still going. The - * BundleLoader and BundleRepository of the Framework are the primary resources - * that are in contention in this deadlock scenario, due to the BundleRepository - * being used as a synchronization lock both deep in - * bundleWiring.getClassloader() and in Framework shutdown code. The other - * resource used as a synchronization lock and causing the deadlock is the - * BundleLoader associated with the bundle. When BundleLoader.findClass() is - * called, it results in a lock on the BundleLoader and then a lock on the - * BundleRepository. This happens when the DefaultClassLoader loads a class. - * - * Therefore to avoid this deadlock, if you are going to call - * BundleWiring.getClassLoader() you should attempt synchronize against the - * BundleLoader and the BundleRepository. This will ensure the call to - * getClassLoader() can finish and then release synchronization locks of both - * the BundleRepository and BundleLoader. - * - * If we fail to get the BundleLoader or BundleRepository, then you should - * proceed onwards anyway because the odds of the application shutting down at - * the same time as the call to BundleWiring.getClassLoader() is still running - * is low. Even if that occurs, the odds are further reduced that the two - * threads will synchronize against the BundleLoader and the BundleRepository at - * the same time and deadlock. - * - *
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 13, 2014 3500 bclement Initial creation - * - *- * - * @author bclement - * @version 1.0 - */ -public class BundleSynchronizer { - - private BundleSynchronizer() { - } - - /** - * Attempts to synchronize with the bundle's BundleLoader and - * BundleRepository objects before running the runner. If either the - * BundleLoader or the BundleRepository are unable to be retrieved from the - * bundle, the runner is ran anyway since the likelihood of a deadlock is - * relatively small. - * - * @param runner - * @param bundle - * @see BundleLoaderGetter#getBundleLoader(Bundle) - * @see BundleRepositoryGetter#getFrameworkBundleRepository(Bundle) - */ - protected static void runSynchedWithBundle(Runnable runner, Bundle bundle) { - BundleRepository repo = BundleRepositoryGetter - .getFrameworkBundleRepository(bundle); - BundleLoader loader = BundleLoaderGetter.getBundleLoader(bundle); - if (repo != null && loader != null) { - synchronized (loader) { - synchronized (repo) { - runner.run(); - } - } - } else { - runner.run(); - } - } -}