org.eclipse.osgi.internal.loader.buddy.PolicyHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aspectjtools Show documentation
Show all versions of aspectjtools Show documentation
Tools from the AspectJ project
/*******************************************************************************
* Copyright (c) 2005, 2016 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.osgi.internal.loader.buddy;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.osgi.container.ModuleContainerAdaptor.ContainerEvent;
import org.eclipse.osgi.internal.framework.EquinoxBundle;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;
import org.osgi.framework.wiring.FrameworkWiring;
public class PolicyHandler implements SynchronousBundleListener {
//Key for the framework buddies
private final static String DEPENDENT_POLICY = "dependent"; //$NON-NLS-1$
private final static String GLOBAL_POLICY = "global"; //$NON-NLS-1$
private final static String REGISTERED_POLICY = "registered"; //$NON-NLS-1$
private final static String APP_POLICY = "app"; //$NON-NLS-1$
private final static String EXT_POLICY = "ext"; //$NON-NLS-1$
private final static String BOOT_POLICY = "boot"; //$NON-NLS-1$
private final static String PARENT_POLICY = "parent"; //$NON-NLS-1$
//The loader to which this policy is attached.
private final BundleLoader policedLoader;
private final List originalBuddyList;
//List of the policies as well as cache for the one that have been created. The size of this array never changes over time. This is why the synchronization is not done when iterating over it.
private volatile Object[] policies = null;
//Support to cut class / resource loading cycles in the context of one thread. The contained object is a set of classname
private final ThreadLocal> beingLoaded;
private final FrameworkWiring frameworkWiring;
private final ClassLoader bootLoader;
public PolicyHandler(BundleLoader loader, List buddyList, FrameworkWiring frameworkWiring,
ClassLoader bootLoader) {
policedLoader = loader;
this.originalBuddyList = buddyList;
policies = buddyList.toArray();
beingLoaded = new ThreadLocal<>();
this.frameworkWiring = frameworkWiring;
this.bootLoader = bootLoader;
}
static Object[] getArrayFromList(String stringList) {
if (stringList == null || stringList.trim().equals("")) //$NON-NLS-1$
return null;
List