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/BundleReflections.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java index a39a53ddad..d965f88f5b 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java @@ -49,6 +49,7 @@ import org.reflections.util.ConfigurationBuilder; * Jan 22, 2014 2062 bsteffen Handle bundles with no wiring. * Apr 16, 2014 3018 njensen Synchronize against BundleRepository * Aug 13, 2014 3500 bclement uses BundleSynchronizer + * Aug 22, 2014 3500 bclement removed sync on OSGi internals * * * @@ -61,17 +62,11 @@ public class BundleReflections { private final Reflections reflections; public BundleReflections(Bundle bundle, Scanner scanner) throws IOException { - final ConfigurationBuilder cb = new ConfigurationBuilder(); - final BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); + ConfigurationBuilder cb = new ConfigurationBuilder(); + BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); if (bundleWiring != null) { - BundleSynchronizer.runSynchedWithBundle(new Runnable() { - @Override - public void run() { - cb.addClassLoader(bundleWiring.getClassLoader()); - - } - }, bundle); + cb.addClassLoader(bundleWiring.getClassLoader()); cb.addUrls(FileLocator.getBundleFile(bundle).toURI().toURL()); cb.setScanners(scanner); diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleRepositoryGetter.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleRepositoryGetter.java deleted file mode 100644 index 36262c6311..0000000000 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleRepositoryGetter.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 java.lang.reflect.Field; - -import org.eclipse.osgi.framework.internal.core.AbstractBundle; -import org.eclipse.osgi.framework.internal.core.BundleRepository; -import org.eclipse.osgi.framework.internal.core.Framework; -import org.osgi.framework.Bundle; - -/** - * Utility class to get the BundleRepository object associated with a Bundle, to - * potentially synchronize against that object. - * - * - *
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Apr 17, 2014 njensen Initial creation - * Aug 13, 2014 3500 bclement moved documentation over to BundleSynchronizer - * - *- * - * @author njensen - * @version 1.0 - * @see BundleSynchronizer - */ -public class BundleRepositoryGetter { - - private BundleRepositoryGetter() { - - } - - /** - * Attempts to retrieve the BundleRepository associated with the bundle's - * framework. Returns the BundleRepository or null if it could not be - * retrieved. - * - * @param bundle - * the bundle to retrieve the associated BundleRepository for - * @return the BundleRepository or null - */ - @SuppressWarnings("restriction") - protected static BundleRepository getFrameworkBundleRepository(Bundle bundle) { - BundleRepository bundleRepo = null; - if (bundle instanceof AbstractBundle) { - try { - AbstractBundle ab = (AbstractBundle) bundle; - Field bundleRepoField = Framework.getField(Framework.class, - BundleRepository.class, true); - bundleRepo = (BundleRepository) bundleRepoField.get(ab - .getFramework()); - } catch (Throwable t) { - // intentionally log to console and proceed anyway - t.printStackTrace(); - } - } - - return bundleRepo; - } - -} 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(); - } - } -} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java index a6c40caf79..e02f2dad87 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java @@ -58,6 +58,7 @@ import com.raytheon.uf.viz.core.Activator; * Feb 03, 2013 2764 bsteffen Use OSGi API to get dependencies. * Apr 17, 2014 3018 njensen Synchronize against BundleRepository * Aug 13, 2014 3500 bclement uses BundleSynchronizer + * Aug 22, 2014 3500 bclement removed sync on OSGi internals * * * @@ -265,20 +266,12 @@ public class SubClassLocator implements ISubClassLocator { */ private Set